mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-23 11:57:17 +00:00
24 lines
402 B
Go
24 lines
402 B
Go
|
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
|
||
|
}
|