File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
1
package disco
2
2
3
+ import "strings"
4
+
3
5
type PeerID string
4
6
5
7
func (id PeerID ) String () string {
@@ -17,3 +19,21 @@ func (id PeerID) Len() byte {
17
19
func (id PeerID ) Bytes () []byte {
18
20
return []byte (id )
19
21
}
22
+
23
+ type Labels []string
24
+
25
+ func (ls Labels ) Get (key string ) (string , bool ) {
26
+ for _ , l := range ls {
27
+ kv := strings .Split (l , "=" )
28
+ if len (kv ) == 2 {
29
+ if kv [0 ] == key {
30
+ return kv [1 ], true
31
+ }
32
+ continue
33
+ }
34
+ if kv [0 ] == key {
35
+ return "" , true
36
+ }
37
+ }
38
+ return "" , false
39
+ }
Original file line number Diff line number Diff line change @@ -270,8 +270,12 @@ func (c *PacketConn) relayPeer(peerID disco.PeerID) disco.PeerID {
270
270
if meta == nil {
271
271
continue
272
272
}
273
+ if _ , ok := disco .Labels (meta ["label" ]).Get ("node.nr" ); ok {
274
+ // can not as relay peer when `node.nr` label is present
275
+ continue
276
+ }
273
277
peerNAT := disco .NATType (meta .Get ("nat" ))
274
- if peerNAT == disco .Easy || peerNAT == disco .IP4 {
278
+ if peerNAT == disco .Easy || peerNAT == disco .IP4 || peerNAT == disco . IP46 {
275
279
return p .PeerID
276
280
}
277
281
}
You can’t perform that action at this time.
0 commit comments