From: Sergey Matveev Date: Sat, 25 Feb 2017 08:48:23 +0000 (+0300) Subject: Split too long lines X-Git-Url: http://www.git.cypherpunks.ru/?p=govpn.git;a=commitdiff_plain;h=f3e3de2b0169bbecad4aefaf8902cbb4a1d9ce6a Split too long lines --- diff --git a/src/cypherpunks.ru/govpn/action.go b/src/cypherpunks.ru/govpn/action.go index 5251dd3..af1b304 100644 --- a/src/cypherpunks.ru/govpn/action.go +++ b/src/cypherpunks.ru/govpn/action.go @@ -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, + ) } } diff --git a/src/cypherpunks.ru/govpn/client/tcp.go b/src/cypherpunks.ru/govpn/client/tcp.go index 056b40e..eca4852 100644 --- a/src/cypherpunks.ru/govpn/client/tcp.go +++ b/src/cypherpunks.ru/govpn/client/tcp.go @@ -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") diff --git a/src/cypherpunks.ru/govpn/common.go b/src/cypherpunks.ru/govpn/common.go index 002b1fb..003792e 100644 --- a/src/cypherpunks.ru/govpn/common.go +++ b/src/cypherpunks.ru/govpn/common.go @@ -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 { diff --git a/src/cypherpunks.ru/govpn/peer.go b/src/cypherpunks.ru/govpn/peer.go index 24f6945..b6aa605 100644 --- a/src/cypherpunks.ru/govpn/peer.go +++ b/src/cypherpunks.ru/govpn/peer.go @@ -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) diff --git a/src/cypherpunks.ru/govpn/stats.go b/src/cypherpunks.ru/govpn/stats.go index bde60e7..757eb55 100644 --- a/src/cypherpunks.ru/govpn/stats.go +++ b/src/cypherpunks.ru/govpn/stats.go @@ -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 {