"Alice": {
"up": "/path/to/up.sh",
+ "iface": "or TAP interface name",
"verifier": "$argon2d$m=4096,t=128,p=1$bwR5VjeCYIQaa8SeaI3rqg$KCNIqfS4DGsBTtVytamAzcISgrlEWvNxan1UfBrFu10"
}
@end verbatim
@strong{Prepare the server}. Add this entry to @code{peers.json}
-configuration file.
+configuration file:
+
+@verbatim
+{
+ "Alice": {
+ "iface": "tap10",
+ "verifier": "$argon2d$m=4096,t=128,p=1$bwR5VjeCYIQaa8SeaI3rqg$KCNIqfS4DGsBTtVytamAzcISgrlEWvNxan1UfBrFu10"
+ }
+}
+@end verbatim
@strong{Prepare network on GNU/Linux IPv4 server}:
@example
server% umask 077
-server% echo "#!/bin/sh" > /path/to/up.sh
-server% echo "echo tap10" >> /path/to/up.sh
server% ip addr add 192.168.0.1/24 dev wlan0
server% tunctl -t tap10
server% ip link set mtu 1432 dev tap10
@verbatim
{
"stargrave": { <-- Peer human readable name
- "up": "./stargrave-up.sh", <-- up-script
+ "iface": "tap10", <-- OPTIONAL TAP interface name
+ "up": "./stargrave-up.sh", <-- OPTIONAL up-script
"down": "./stargrave-down.sh", <-- OPTIONAL down-script
"timeout": 60, <-- OPTIONAL overriden timeout
"noise": true, <-- OPTIONAL noise enabler
}
@end verbatim
-up-script executes each time connection with the client is established.
-Its @emph{stdout} output must contain TAP interface name as the first
-line. This script can be simple @code{echo tap10}, or maybe more
-advanced like this:
+At least one of either @code{iface} or @code{up} must be specified. If
+you specify @code{iface}, then it will be forcefully used to determine
+what TAP interface will be used. If it is not specified, then up-script
+must output interface's name to stdout (first output line).
+
+For example up-script can be just @code{echo tap10}, or more advanced
+like the following one:
+
@example
#!/bin/sh
$tap=$(ifconfig tap create)
"Alice": {
"up": "/path/to/up.sh",
+ "iface": "or TAP interface name",
"verifier": "$argon2d$m=4096,t=128,p=1$bwR5VjeCYIQaa8SeaI3rqg$KCNIqfS4DGsBTtVytamAzcISgrlEWvNxan1UfBrFu10"
}
[...]
}
conf = &govpn.PeerConf{
Id: verifier.Id,
+ Iface: *ifaceName,
Timeout: time.Second * time.Duration(timeout),
Noise: *noisy,
CPR: *cpr,
}
func callUp(peerId *govpn.PeerId) (string, error) {
- result, err := govpn.ScriptCall(confs[*peerId].Up, "")
- if err != nil {
- log.Println("Script", confs[*peerId].Up, "call failed", err)
- return "", err
+ ifaceName := confs[*peerId].Iface
+ if confs[*peerId].Up != "" {
+ result, err := govpn.ScriptCall(confs[*peerId].Up, "")
+ if err != nil {
+ log.Println("Script", confs[*peerId].Up, "call failed", err)
+ return "", err
+ }
+ if ifaceName == "" {
+ sepIndex := bytes.Index(result, []byte{'\n'})
+ if sepIndex < 0 {
+ sepIndex = len(result)
+ }
+ ifaceName = string(result[:sepIndex])
+ }
}
- sepIndex := bytes.Index(result, []byte{'\n'})
- if sepIndex < 0 {
- sepIndex = len(result)
+ if ifaceName == "" {
+ log.Println("Can not obtain interface name for", *peerId)
}
- ifaceName := string(result[:sepIndex])
return ifaceName, nil
}
Verifier: verifier,
Id: verifier.Id,
Name: name,
+ Iface: pc.Iface,
Up: pc.Up,
Down: pc.Down,
Noise: pc.Noise,
type PeerConf struct {
Id *PeerId `json:"-"`
Name string `json:"name"`
+ Iface string `json:"iface"`
Up string `json:"up"`
Down string `json:"down"`
TimeoutInt int `json:"timeout"`
"$username": {
"up": "/path/to/up.sh",
+ "iface": "or TAP interface name",
"verifier": "$verifierS"
}