mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
style: fmt
This commit is contained in:
@@ -4,8 +4,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"github.com/cnlh/nps/lib/crypt"
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
"html/template"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -16,6 +14,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/cnlh/nps/lib/crypt"
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
)
|
||||
|
||||
//Get the corresponding IP address through domain name
|
||||
|
@@ -3,10 +3,11 @@ package config
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/cnlh/nps/lib/file"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/cnlh/nps/lib/file"
|
||||
)
|
||||
|
||||
type CommonConfig struct {
|
||||
|
@@ -6,13 +6,6 @@ import (
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/cnlh/nps/lib/crypt"
|
||||
"github.com/cnlh/nps/lib/file"
|
||||
"github.com/cnlh/nps/lib/mux"
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
"github.com/cnlh/nps/lib/rate"
|
||||
"github.com/xtaci/kcp-go"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -21,6 +14,14 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/cnlh/nps/lib/crypt"
|
||||
"github.com/cnlh/nps/lib/file"
|
||||
"github.com/cnlh/nps/lib/mux"
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
"github.com/cnlh/nps/lib/rate"
|
||||
"github.com/xtaci/kcp-go"
|
||||
)
|
||||
|
||||
type Conn struct {
|
||||
@@ -373,7 +374,7 @@ func CopyWaitGroup(conn1, conn2 net.Conn, crypt bool, snappy bool, rate *rate.Ra
|
||||
}
|
||||
|
||||
//get crypt or snappy conn
|
||||
func GetConn(conn net.Conn, cpt, snappy bool, rt *rate.Rate, isServer bool) (io.ReadWriteCloser) {
|
||||
func GetConn(conn net.Conn, cpt, snappy bool, rt *rate.Rate, isServer bool) io.ReadWriteCloser {
|
||||
if cpt {
|
||||
if isServer {
|
||||
return rate.NewRateConn(crypt.NewTlsServerConn(conn), rt)
|
||||
|
@@ -1,10 +1,11 @@
|
||||
package conn
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/xtaci/kcp-go"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/xtaci/kcp-go"
|
||||
)
|
||||
|
||||
func NewTcpListenerAndProcess(addr string, f func(c net.Conn), listener *net.Listener) error {
|
||||
|
@@ -1,9 +1,10 @@
|
||||
package conn
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
"github.com/golang/snappy"
|
||||
"io"
|
||||
)
|
||||
|
||||
type SnappyConn struct {
|
||||
|
@@ -2,9 +2,10 @@ package crypt
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
)
|
||||
|
||||
var pemPath, keyPath string
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
@@ -9,6 +8,8 @@ import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
)
|
||||
|
||||
func InitDaemon(f string, runPath string, pidPath string) {
|
||||
|
@@ -3,12 +3,13 @@
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/astaxie/beego"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@@ -3,14 +3,15 @@ package file
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/cnlh/nps/lib/crypt"
|
||||
"github.com/cnlh/nps/lib/rate"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/cnlh/nps/lib/crypt"
|
||||
"github.com/cnlh/nps/lib/rate"
|
||||
)
|
||||
|
||||
type DbUtils struct {
|
||||
|
@@ -3,13 +3,14 @@ package file
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/cnlh/nps/lib/rate"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/cnlh/nps/lib/rate"
|
||||
)
|
||||
|
||||
func NewJsonDb(runPath string) *JsonDb {
|
||||
|
@@ -1,12 +1,13 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"github.com/cnlh/nps/lib/rate"
|
||||
"github.com/pkg/errors"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/cnlh/nps/lib/rate"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Flow struct {
|
||||
|
@@ -3,12 +3,13 @@ package install
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
)
|
||||
|
||||
func InstallNps() {
|
||||
|
@@ -2,11 +2,12 @@ package mux
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
"io"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
)
|
||||
|
||||
type conn struct {
|
||||
|
@@ -4,12 +4,13 @@ import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
"math"
|
||||
"net"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -174,7 +175,7 @@ func (s *Mux) readSession() {
|
||||
case conn.getStatusCh <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
conn.hasWrite --
|
||||
conn.hasWrite--
|
||||
case MUX_NEW_CONN_OK: //conn ok
|
||||
conn.connStatusOkCh <- struct{}{}
|
||||
case MUX_NEW_CONN_Fail:
|
||||
|
@@ -1,15 +1,16 @@
|
||||
package mux
|
||||
|
||||
import (
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
)
|
||||
|
||||
var conn1 net.Conn
|
||||
|
@@ -5,15 +5,16 @@ package mux
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/pkg/errors"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@@ -1,9 +1,10 @@
|
||||
package mux
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
)
|
||||
|
||||
func TestPortMux_Close(t *testing.T) {
|
||||
@@ -11,7 +12,7 @@ func TestPortMux_Close(t *testing.T) {
|
||||
logs.EnableFuncCallDepth(true)
|
||||
logs.SetLogFuncCallDepth(3)
|
||||
|
||||
pMux := NewPortMux(8888,"Ds")
|
||||
pMux := NewPortMux(8888, "Ds")
|
||||
go func() {
|
||||
if pMux.Start() != nil {
|
||||
logs.Warn("Error")
|
||||
|
@@ -2,8 +2,9 @@ package mux
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
"sync"
|
||||
|
||||
"github.com/cnlh/nps/lib/pool"
|
||||
)
|
||||
|
||||
type Element *bufNode
|
||||
|
@@ -36,6 +36,7 @@ var BufPoolCopy = sync.Pool{
|
||||
return &buf
|
||||
},
|
||||
}
|
||||
|
||||
func PutBufPoolUdp(buf []byte) {
|
||||
if cap(buf) == PoolSizeUdp {
|
||||
BufPoolUdp.Put(buf[:PoolSizeUdp])
|
||||
@@ -48,7 +49,7 @@ func PutBufPoolCopy(buf []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetBufPoolCopy() ([]byte) {
|
||||
func GetBufPoolCopy() []byte {
|
||||
return (*BufPoolCopy.Get().(*[]byte))[:PoolSizeCopy]
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user