mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
402 B
24 lines
402 B
10 years ago
|
package p2p
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"net"
|
||
|
)
|
||
|
|
||
|
func ParseNAT(natType string, gateway string) (nat NAT, err error) {
|
||
|
switch natType {
|
||
|
case "UPNP":
|
||
|
nat = UPNP()
|
||
|
case "PMP":
|
||
|
ip := net.ParseIP(gateway)
|
||
|
if ip == nil {
|
||
|
return nil, fmt.Errorf("cannot resolve PMP gateway IP %s", gateway)
|
||
|
}
|
||
|
nat = PMP(ip)
|
||
|
case "":
|
||
|
default:
|
||
|
return nil, fmt.Errorf("unrecognised NAT type '%s'", natType)
|
||
|
}
|
||
|
return
|
||
|
}
|