@ -238,19 +238,24 @@ func (nm *NetworkMap) _WireGuardConfig(uflags int, dnsOverride []wgcfg.IP, allEn
}
}
fmt . Fprintf ( buf , "[Peer]\n" )
fmt . Fprintf ( buf , "[Peer]\n" )
fmt . Fprintf ( buf , "PublicKey = %s\n" , base64 . StdEncoding . EncodeToString ( peer . Key [ : ] ) )
fmt . Fprintf ( buf , "PublicKey = %s\n" , base64 . StdEncoding . EncodeToString ( peer . Key [ : ] ) )
if len ( peer . Endpoints ) > 0 {
var endpoints [ ] string
if len ( peer . Endpoints ) == 1 {
if peer . DERP != "" {
fmt . Fprintf ( buf , "Endpoint = %s" , peer . Endpoints [ 0 ] )
endpoints = append ( endpoints , peer . DERP )
}
endpoints = append ( endpoints , peer . Endpoints ... )
if len ( endpoints ) > 0 {
if len ( endpoints ) == 1 {
fmt . Fprintf ( buf , "Endpoint = %s" , endpoints [ 0 ] )
} else if allEndpoints {
} else if allEndpoints {
// TODO(apenwarr): This mode is incompatible.
// TODO(apenwarr): This mode is incompatible.
// Normal wireguard clients don't know how to
// Normal wireguard clients don't know how to
// parse it (yet?)
// parse it (yet?)
fmt . Fprintf ( buf , "Endpoint = %s" ,
fmt . Fprintf ( buf , "Endpoint = %s" ,
strings . Join ( p eer. E ndpoints, "," ) )
strings . Join ( endpoints, "," ) )
} else {
} else {
fmt . Fprintf ( buf , "Endpoint = %s # other endpoints: %s" ,
fmt . Fprintf ( buf , "Endpoint = %s # other endpoints: %s" ,
p eer. E ndpoints[ 0 ] ,
endpoints[ 0 ] ,
strings . Join ( p eer. E ndpoints[ 1 : ] , ", " ) )
strings . Join ( endpoints[ 1 : ] , ", " ) )
}
}
buf . WriteByte ( '\n' )
buf . WriteByte ( '\n' )
}
}