/*
GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
+ 2016-2017 Bruno Clermont <bruno@robotinfra.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
"github.com/pkg/errors"
)
-// PeerContext hold info about a peer that connect or disconnect
+// PeerContext holds info about a peer that connect or disconnect
// used for Up, PreUp and Down
type PeerContext struct {
RemoteAddress string
// after user is authenticated
type TunnelPreUpAction func(PeerContext) (*TAP, error)
-// RunScriptAction convert the path to a script into a TunnelAction
+// RunScriptAction converts the path to a script into a TunnelAction
func RunScriptAction(path *string) TunnelAction {
if path == nil {
return nil
}
}
-// ScriptCall call external program/script.
+// ScriptCall calls external program/script.
// You have to specify path to it and (inteface name as a rule) something
// that will be the first argument when calling it. Function will return
// it's output and possible error.
ProxyAuthentication string
RemoteAddress string
NoReconnect bool
- // FileDescriptor allow to create a Client from a pre-existing file descriptor.
- // Required for Android. requires TCP protocol
+ // FileDescriptor allows creating Client from a pre-existing file
+ // descriptor. Required for Android. Requires TCP transport.
FileDescriptor int
}
return errors.New("Missing RemoteAddress")
}
if len(c.Peer.Iface) == 0 && c.Peer.PreUp == nil {
- return errors.New("Missing InterfaceName *or* PreUp")
+ return errors.New("Missing InterfaceName or PreUp")
}
if c.Protocol != govpn.ProtocolTCP && c.Protocol != govpn.ProtocolUDP {
return errors.Errorf("Invalid protocol %d for client", c.Protocol)
}
if c.FileDescriptor > 0 && c.Protocol != govpn.ProtocolTCP {
- return errors.Errorf("Connect with file descriptor requires protocol %s", govpn.ProtocolTCP.String())
+ return errors.Errorf(
+ "Connect with file descriptor requires protocol %s",
+ govpn.ProtocolTCP.String(),
+ )
}
return nil
}
-// LogFields return a logrus compatible logging context
+// LogFields returns a logrus compatible logging context
func (c *Configuration) LogFields() logrus.Fields {
const prefix = "client_conf_"
f := c.Peer.LogFields(prefix)
Error chan error
}
-// LogFields return a logrus compatible logging context
+// LogFields returns a logrus compatible logging context
func (c *Client) LogFields() logrus.Fields {
const prefix = "client_"
f := logrus.Fields{
return errors.Wrap(err, "c.config.Peer.Up")
}
-// KnownPeers return GoVPN peers. Always 1.
-// used to get client statistics.
+// KnownPeers returns GoVPN peers. Always 1. Used to get client statistics.
func (c *Client) KnownPeers() *govpn.KnownPeers {
return &c.knownPeers
}
l.Debug("No PreUp to run")
}
- // if tap wasn't set by PreUp, listen here
+ // if TAP wasn't set by PreUp, listen here
if c.tap == nil {
l.WithField("asking", c.config.Peer.Iface).Debug("No interface, try to listen")
c.tap, err = govpn.TAPListen(c.config.Peer.Iface, c.config.Peer.MTU)
if err != nil {
- c.Error <- errors.Wrapf(err, "govpn.TAPListen inteface:%s mtu:%d", c.config.Peer.Iface, c.config.Peer.MTU)
+ c.Error <- errors.Wrapf(
+ err,
+ "govpn.TAPListen inteface:%s mtu:%d",
+ c.config.Peer.Iface, c.config.Peer.MTU,
+ )
return
}
}
}
if resp.StatusCode != http.StatusOK {
govpn.CloseLog(conn, c.logger, c.LogFields())
- c.Error <- errors.Errorf("Unexpected response from proxy: %s", http.StatusText(resp.StatusCode))
+ c.Error <- errors.Errorf(
+ "Unexpected response from proxy: %s",
+ http.StatusText(resp.StatusCode),
+ )
return
}
- c.logger.WithField("func", logFuncPrefix+"Client.proxyTCP").WithFields(c.config.LogFields()).Debug("Proxy connected")
+ c.logger.WithField(
+ "func", logFuncPrefix+"Client.proxyTCP",
+ ).WithFields(
+ c.config.LogFields(),
+ ).Debug("Proxy connected")
go c.handleTCP(conn)
}
/*
GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/*
GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/*
GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by