From 6f7f0571f11f3d370b38c6de681e4b1389ba3e53 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 25 Feb 2017 11:15:18 +0300 Subject: [PATCH] Copyright and stylistic changes --- src/cypherpunks.ru/govpn/action.go | 9 ++++--- src/cypherpunks.ru/govpn/client/client.go | 26 ++++++++++++------- src/cypherpunks.ru/govpn/client/proxy.go | 11 ++++++-- src/cypherpunks.ru/govpn/client/udp.go | 2 +- .../govpn/cmd/govpn-client/main.go | 2 +- src/cypherpunks.ru/govpn/conf.go | 2 +- 6 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/cypherpunks.ru/govpn/action.go b/src/cypherpunks.ru/govpn/action.go index 5ad35b2..5251dd3 100644 --- a/src/cypherpunks.ru/govpn/action.go +++ b/src/cypherpunks.ru/govpn/action.go @@ -1,6 +1,7 @@ /* GoVPN -- simple secure free software virtual private network daemon -Copyright (C) 2014-2016 Sergey Matveev +Copyright (C) 2014-2017 Sergey Matveev + 2016-2017 Bruno Clermont 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 @@ -25,7 +26,7 @@ import ( "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 @@ -41,7 +42,7 @@ type TunnelAction func(PeerContext) error // 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 @@ -52,7 +53,7 @@ func RunScriptAction(path *string) TunnelAction { } } -// 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. diff --git a/src/cypherpunks.ru/govpn/client/client.go b/src/cypherpunks.ru/govpn/client/client.go index d04dc6b..4ebd8a9 100644 --- a/src/cypherpunks.ru/govpn/client/client.go +++ b/src/cypherpunks.ru/govpn/client/client.go @@ -40,8 +40,8 @@ type Configuration struct { 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 } @@ -54,18 +54,21 @@ func (c *Configuration) Validate() error { 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) @@ -103,7 +106,7 @@ type Client struct { 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{ @@ -142,8 +145,7 @@ func (c *Client) postUpAction() error { 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 } @@ -170,12 +172,16 @@ func (c *Client) MainCycle() { 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 } } diff --git a/src/cypherpunks.ru/govpn/client/proxy.go b/src/cypherpunks.ru/govpn/client/proxy.go index 9ee1208..31d7897 100644 --- a/src/cypherpunks.ru/govpn/client/proxy.go +++ b/src/cypherpunks.ru/govpn/client/proxy.go @@ -63,9 +63,16 @@ func (c *Client) proxyTCP() { } 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) } diff --git a/src/cypherpunks.ru/govpn/client/udp.go b/src/cypherpunks.ru/govpn/client/udp.go index 24702f3..a4bbcf7 100644 --- a/src/cypherpunks.ru/govpn/client/udp.go +++ b/src/cypherpunks.ru/govpn/client/udp.go @@ -1,6 +1,6 @@ /* GoVPN -- simple secure free software virtual private network daemon -Copyright (C) 2014-2016 Sergey Matveev +Copyright (C) 2014-2017 Sergey Matveev 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 diff --git a/src/cypherpunks.ru/govpn/cmd/govpn-client/main.go b/src/cypherpunks.ru/govpn/cmd/govpn-client/main.go index f6530df..31f9e6e 100644 --- a/src/cypherpunks.ru/govpn/cmd/govpn-client/main.go +++ b/src/cypherpunks.ru/govpn/cmd/govpn-client/main.go @@ -1,6 +1,6 @@ /* GoVPN -- simple secure free software virtual private network daemon -Copyright (C) 2014-2016 Sergey Matveev +Copyright (C) 2014-2017 Sergey Matveev 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 diff --git a/src/cypherpunks.ru/govpn/conf.go b/src/cypherpunks.ru/govpn/conf.go index 825a0cf..ba7c3b8 100644 --- a/src/cypherpunks.ru/govpn/conf.go +++ b/src/cypherpunks.ru/govpn/conf.go @@ -1,6 +1,6 @@ /* GoVPN -- simple secure free software virtual private network daemon -Copyright (C) 2014-2016 Sergey Matveev +Copyright (C) 2014-2017 Sergey Matveev 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 -- 2.44.0