Merge pull request #164 from exfly/feat/go-mod-supported

feat: go mod supported
This commit is contained in:
ffdfgdfg
2019-08-19 09:35:14 +08:00
committed by GitHub
316 changed files with 382 additions and 62787 deletions

View File

@@ -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

View File

@@ -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 {

View File

@@ -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/cnlh/nps/vender/github.com/xtaci/kcp"
"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)

View File

@@ -1,10 +1,11 @@
package conn
import (
"github.com/cnlh/nps/vender/github.com/astaxie/beego/logs"
"github.com/cnlh/nps/vender/github.com/xtaci/kcp"
"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 {

View File

@@ -1,9 +1,10 @@
package conn
import (
"github.com/cnlh/nps/lib/pool"
"github.com/cnlh/nps/vender/github.com/golang/snappy"
"io"
"github.com/cnlh/nps/lib/pool"
"github.com/golang/snappy"
)
type SnappyConn struct {

View File

@@ -2,9 +2,10 @@ package crypt
import (
"crypto/tls"
"github.com/cnlh/nps/vender/github.com/astaxie/beego/logs"
"net"
"os"
"github.com/astaxie/beego/logs"
)
var pemPath, keyPath string

View File

@@ -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) {

View File

@@ -3,12 +3,13 @@
package daemon
import (
"github.com/cnlh/nps/lib/common"
"github.com/cnlh/nps/vender/github.com/astaxie/beego"
"os"
"os/signal"
"path/filepath"
"syscall"
"github.com/astaxie/beego"
"github.com/cnlh/nps/lib/common"
)
func init() {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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() {

View File

@@ -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 {

View File

@@ -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:

View File

@@ -1,15 +1,16 @@
package mux
import (
"github.com/cnlh/nps/lib/common"
"github.com/cnlh/nps/lib/pool"
"github.com/cnlh/nps/vender/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

View File

@@ -5,15 +5,16 @@ package mux
import (
"bufio"
"bytes"
"github.com/cnlh/nps/lib/common"
"github.com/cnlh/nps/vender/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 (

View File

@@ -1,9 +1,10 @@
package mux
import (
"github.com/cnlh/nps/vender/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")

View File

@@ -2,8 +2,9 @@ package mux
import (
"errors"
"github.com/cnlh/nps/lib/pool"
"sync"
"github.com/cnlh/nps/lib/pool"
)
type Element *bufNode

View File

@@ -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]
}