]> Cypherpunks.ru repositories - govpn.git/commitdiff
Split too long lines
authorSergey Matveev <stargrave@stargrave.org>
Sat, 25 Feb 2017 08:48:23 +0000 (11:48 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 25 Feb 2017 09:18:10 +0000 (12:18 +0300)
src/cypherpunks.ru/govpn/action.go
src/cypherpunks.ru/govpn/client/tcp.go
src/cypherpunks.ru/govpn/common.go
src/cypherpunks.ru/govpn/peer.go
src/cypherpunks.ru/govpn/stats.go

index 5251dd3dd6cf05f028ed3bd312dc0e4475a06faa..af1b3044c383cf7e9423fc37823aab4f454cf1f8 100644 (file)
@@ -49,7 +49,13 @@ func RunScriptAction(path *string) TunnelAction {
        }
        return func(ctx PeerContext) error {
                _, err := ScriptCall(*path, ctx.Config.Iface, ctx.RemoteAddress)
-               return errors.Wrapf(err, "ScriptCall path=%q interface=%q remote=%q", *path, ctx.Config.Iface, ctx.RemoteAddress)
+               return errors.Wrapf(
+                       err,
+                       "ScriptCall path=%q interface=%q remote=%q",
+                       *path,
+                       ctx.Config.Iface,
+                       ctx.RemoteAddress,
+               )
        }
 }
 
index 056b40e36e5ca2e0b6f38a1e53cb381c7f9bad71..eca48521bc446eb84f846634dd5c4542ddcaf831 100644 (file)
@@ -39,7 +39,10 @@ func (c *Client) startTCP() {
        if c.config.FileDescriptor > 0 {
                l.WithField("fd", c.config.FileDescriptor).Debug("Connect using file descriptor")
                var err error
-               conn, err = net.FileConn(os.NewFile(uintptr(c.config.FileDescriptor), fmt.Sprintf("fd[%s]", c.config.RemoteAddress)))
+               conn, err = net.FileConn(os.NewFile(
+                       uintptr(c.config.FileDescriptor),
+                       fmt.Sprintf("fd[%s]", c.config.RemoteAddress),
+               ))
                if err != nil {
                        c.Error <- errors.Wrapf(err, "net.FileConn fd:%d", c.config.FileDescriptor)
                        return
@@ -86,7 +89,9 @@ HandshakeCycle:
                default:
                }
                if prev == len(buf) {
-                       c.logger.WithFields(fields).WithFields(c.LogFields()).Debug("Packet timeouted")
+                       c.logger.WithFields(fields).WithFields(
+                               c.LogFields(),
+                       ).Debug("Packet timeouted")
                        c.timeouted <- struct{}{}
                        break HandshakeCycle
                }
@@ -98,7 +103,9 @@ HandshakeCycle:
                }
                n, err = conn.Read(buf[prev:])
                if err != nil {
-                       c.logger.WithFields(fields).WithFields(c.LogFields()).Debug("Packet timeouted")
+                       c.logger.WithFields(fields).WithFields(
+                               c.LogFields(),
+                       ).Debug("Packet timeouted")
                        c.timeouted <- struct{}{}
                        break HandshakeCycle
                }
@@ -106,13 +113,17 @@ HandshakeCycle:
                prev += n
                _, err = c.idsCache.Find(buf[:prev])
                if err != nil {
-                       c.logger.WithFields(fields).WithFields(c.LogFields()).WithError(err).Debug("Couldn't find peer in ids")
+                       c.logger.WithFields(fields).WithFields(
+                               c.LogFields(),
+                       ).WithError(err).Debug("Can't find peer in ids")
                        continue
                }
                peer, err = hs.Client(buf[:prev])
                prev = 0
                if err != nil {
-                       c.logger.WithFields(fields).WithError(err).WithFields(c.LogFields()).Debug("Can't create new peer")
+                       c.logger.WithFields(fields).WithError(err).WithFields(
+                               c.LogFields(),
+                       ).Debug("Can't create new peer")
                        continue
                }
                c.logger.WithFields(fields).WithFields(c.LogFields()).Info("Handshake completed")
index 002b1fbfd43a55ba72c8a6704b93abd550dbb86f..003792e7d7d32a8ed5d58a678bd88af4346b7cae 100644 (file)
@@ -89,7 +89,11 @@ func (p Protocol) MarshalJSON() ([]byte, error) {
 func (p *Protocol) UnmarshalJSON(encoded []byte) error {
        var str string
        if err := json.Unmarshal(encoded, &str); err != nil {
-               return errors.Wrapf(err, "Can't unmarshall to string %q", hex.EncodeToString(encoded))
+               return errors.Wrapf(
+                       err,
+                       "Can't unmarshall to string %q",
+                       hex.EncodeToString(encoded),
+               )
        }
        proto, err := NewProtocolFromString(str)
        if err != nil {
index 24f694557844216cc5610c87978b069dc0a75f27..b6aa605ed3aac6dfa45cf23520b187195279f854 100644 (file)
@@ -295,7 +295,9 @@ func (p *Peer) EthProcess(data []byte) error {
        const paddingSize = 1
        lenData := len(data)
        if lenData > p.MTU-paddingSize {
-               logger.WithFields(p.LogFields()).WithFields(p.ConfigurationLogFields()).WithFields(
+               logger.WithFields(p.LogFields()).WithFields(
+                       p.ConfigurationLogFields(),
+               ).WithFields(
                        logrus.Fields{
                                "func":        logFuncPrefix + "Peer.EthProcess",
                                "padding":     paddingSize,
@@ -362,7 +364,9 @@ func (p *Peer) PktProcess(data []byte, tap io.Writer, reorderable bool) bool {
                "data":        lenData,
        }
        if lenData < MinPktLength {
-               logger.WithFields(p.LogFields()).WithFields(fields).WithField("minimum_packet_Length", MinPktLength).Debug("Ignore packet smaller than allowed minimum")
+               logger.WithFields(p.LogFields()).WithFields(fields).WithField(
+                       "minimum_packet_Length", MinPktLength,
+               ).Debug("Ignore packet smaller than allowed minimum")
                return false
        }
        if !p.Encless && lenData > len(p.bufR)-chacha20InternalBlockSize {
@@ -490,13 +494,21 @@ func PeerTapProcessor(peer *Peer, tap *TAP, terminator chan struct{}) {
                                now = time.Now()
                                if lastSent.Add(peer.Timeout).Before(now) {
                                        if err = peer.EthProcess(nil); err != nil {
-                                               logger.WithFields(fields).WithFields(peer.LogFields()).WithError(err).Warn("Can't process nil ethernet packet")
+                                               logger.WithFields(
+                                                       fields,
+                                               ).WithFields(
+                                                       peer.LogFields(),
+                                               ).WithError(err).Warn(
+                                                       "Can't process nil ethernet packet",
+                                               )
                                        }
                                        lastSent = now
                                }
                        case data = <-tap.Sink:
                                if err = peer.EthProcess(data); err != nil {
-                                       logger.WithFields(fields).WithFields(peer.LogFields()).WithError(err).Warn("Can't process ethernet packet")
+                                       logger.WithFields(fields).WithFields(
+                                               peer.LogFields(),
+                                       ).WithError(err).Warn("Can't process ethernet packet")
                                }
                                lastSent = time.Now()
                        }
@@ -510,13 +522,17 @@ func PeerTapProcessor(peer *Peer, tap *TAP, terminator chan struct{}) {
                                break CPRProcessor
                        case data = <-tap.Sink:
                                if err = peer.EthProcess(data); err != nil {
-                                       logger.WithFields(fields).WithFields(peer.LogFields()).WithError(err).Warn("Can't process ethernet packet")
+                                       logger.WithFields(fields).WithFields(
+                                               peer.LogFields(),
+                                       ).WithError(err).Warn("Can't process ethernet packet")
                                }
                        default:
                        }
                        if data == nil {
                                if err = peer.EthProcess(nil); err != nil {
-                                       logger.WithFields(fields).WithFields(peer.LogFields()).WithError(err).Warn("Can't process nil ethernet packet")
+                                       logger.WithFields(fields).WithFields(
+                                               peer.LogFields(),
+                                       ).WithError(err).Warn("Can't process nil ethernet packet")
                                }
                        }
                        time.Sleep(peer.CPRCycle)
index bde60e7a470026d8f7f96a63804876a618e6f3e9..757eb55676fbc7eacba078a0f161ab21903eb2cf 100644 (file)
@@ -46,10 +46,14 @@ func StatsProcessor(stats string, peers *KnownPeers) {
                "port":    stats,
        }
 
-       logger.WithFields(fields).WithField("port", stats).Debug("Stats are going to listen")
+       logger.WithFields(fields).WithField(
+               "port", stats,
+       ).Debug("Stats are going to listen")
        statsPort, err := net.Listen("tcp", stats)
        if err != nil {
-               logger.WithError(err).WithField("stats", stats).Error("Can't listen stats server")
+               logger.WithError(err).WithField(
+                       "stats", stats,
+               ).Error("Can't listen stats server")
                return
        }
 
@@ -61,7 +65,9 @@ func StatsProcessor(stats string, peers *KnownPeers) {
                }
                deadLine := time.Now().Add(rwTimeout)
                if err = conn.SetDeadline(deadLine); err != nil {
-                       logger.WithFields(fields).WithField("deadline", deadLine.String()).WithError(err).Error("Couldn't set deadline")
+                       logger.WithFields(fields).WithField(
+                               "deadline", deadLine.String(),
+                       ).WithError(err).Error("Can't set deadline")
                } else if _, err = conn.Read(buf); err != nil {
                        logger.WithFields(fields).WithError(err).Error("Couldn't read buffer")
                } else if _, err = conn.Write([]byte("HTTP/1.0 200 OK\r\nContent-Type: application/json\r\n\r\n")); err != nil {
@@ -72,7 +78,9 @@ func StatsProcessor(stats string, peers *KnownPeers) {
                                peersList = append(peersList, *peer)
                        }
                        if err = json.NewEncoder(conn).Encode(peersList); err != nil {
-                               logger.WithFields(fields).WithField("peers", len(peersList)).WithError(err).Error("Couldn't encode to JSON")
+                               logger.WithFields(fields).WithField(
+                                       "peers", len(peersList),
+                               ).WithError(err).Error("Can't encode to JSON")
                        }
                }
                if err = conn.Close(); err != nil {