diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-04 21:39:15 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-04 21:39:15 +0800 |
commit | 987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9 (patch) | |
tree | 32ff13edca8c3d9b61b303f7d314291d0f216574 /p2p | |
parent | 1b905675465d96227f1a8144fe592e76f646f559 (diff) | |
parent | 08b03afa4bb3a40d2faf6543bc884a8ece5be2a1 (diff) | |
download | dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar.gz dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar.bz2 dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar.lz dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar.xz dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.tar.zst dexon-987119cd4adcdbc7ebfd0bbb027a0c9e2a7487e9.zip |
Merge branch 'poc8' into docbranch
Diffstat (limited to 'p2p')
-rw-r--r-- | p2p/client_identity.go | 4 | ||||
-rw-r--r-- | p2p/nat.go | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/p2p/client_identity.go b/p2p/client_identity.go index bc865b63b..f15fd01bf 100644 --- a/p2p/client_identity.go +++ b/p2p/client_identity.go @@ -17,10 +17,10 @@ type SimpleClientIdentity struct { customIdentifier string os string implementation string - pubkey string + pubkey []byte } -func NewSimpleClientIdentity(clientIdentifier string, version string, customIdentifier string, pubkey string) *SimpleClientIdentity { +func NewSimpleClientIdentity(clientIdentifier string, version string, customIdentifier string, pubkey []byte) *SimpleClientIdentity { clientIdentity := &SimpleClientIdentity{ clientIdentifier: clientIdentifier, version: version, diff --git a/p2p/nat.go b/p2p/nat.go new file mode 100644 index 000000000..9b771c3e8 --- /dev/null +++ b/p2p/nat.go @@ -0,0 +1,23 @@ +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 +} |