diff --git a/Gopkg.lock b/Gopkg.lock index b410372c..962daf61 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -18,13 +18,15 @@ revision = "6c6a4f5bd5eb5a39f7e289b8f345b55f75e7e3e8" [[projects]] + branch = "master" name = "github.com/fatedier/golib" packages = [ "crypto", "errors", + "io", "pool" ] - revision = "c4d2b1c9ff1798d2d9adfd1d03179579ee054c09" + revision = "0508aee5d2b1b6be52b00cf4cf00e6430a71e39e" [[projects]] branch = "frp" @@ -157,6 +159,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "18beeb7f11c5907cadac3f8958717df5b7353f201181783006076ff2875671e3" + inputs-digest = "4876e5a22dfa4bb103f18d44151253b5e8a321f6b64f5ce6403682750b8ff7d5" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index ca6187e3..f33c2f63 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -35,7 +35,7 @@ [[constraint]] name = "github.com/fatedier/golib" - revision = "c4d2b1c9ff1798d2d9adfd1d03179579ee054c09" + branch = "master" [[constraint]] branch = "frp" diff --git a/client/proxy.go b/client/proxy.go index f1c63217..a4f99c64 100644 --- a/client/proxy.go +++ b/client/proxy.go @@ -27,11 +27,11 @@ import ( "github.com/fatedier/frp/models/msg" "github.com/fatedier/frp/models/plugin" "github.com/fatedier/frp/models/proto/udp" - frpIo "github.com/fatedier/frp/utils/io" "github.com/fatedier/frp/utils/log" frpNet "github.com/fatedier/frp/utils/net" "github.com/fatedier/golib/errors" + frpIo "github.com/fatedier/golib/io" "github.com/fatedier/golib/pool" ) diff --git a/client/visitor.go b/client/visitor.go index 90c292f5..d07eb8e7 100644 --- a/client/visitor.go +++ b/client/visitor.go @@ -29,11 +29,11 @@ import ( "github.com/fatedier/frp/g" "github.com/fatedier/frp/models/config" "github.com/fatedier/frp/models/msg" - frpIo "github.com/fatedier/frp/utils/io" "github.com/fatedier/frp/utils/log" frpNet "github.com/fatedier/frp/utils/net" "github.com/fatedier/frp/utils/util" + frpIo "github.com/fatedier/golib/io" "github.com/fatedier/golib/pool" ) diff --git a/models/plugin/http_proxy.go b/models/plugin/http_proxy.go index 8b6f8c98..5ce2e67c 100644 --- a/models/plugin/http_proxy.go +++ b/models/plugin/http_proxy.go @@ -22,8 +22,9 @@ import ( "net/http" "strings" - frpIo "github.com/fatedier/frp/utils/io" frpNet "github.com/fatedier/frp/utils/net" + + frpIo "github.com/fatedier/golib/io" ) const PluginHttpProxy = "http_proxy" diff --git a/models/plugin/unix_domain_socket.go b/models/plugin/unix_domain_socket.go index c3d50e9a..b1ce6226 100644 --- a/models/plugin/unix_domain_socket.go +++ b/models/plugin/unix_domain_socket.go @@ -19,8 +19,9 @@ import ( "io" "net" - frpIo "github.com/fatedier/frp/utils/io" frpNet "github.com/fatedier/frp/utils/net" + + frpIo "github.com/fatedier/golib/io" ) const PluginUnixDomainSocket = "unix_domain_socket" diff --git a/server/manager.go b/server/manager.go index ebc0928f..2c7120ba 100644 --- a/server/manager.go +++ b/server/manager.go @@ -19,9 +19,10 @@ import ( "io" "sync" - frpIo "github.com/fatedier/frp/utils/io" frpNet "github.com/fatedier/frp/utils/net" "github.com/fatedier/frp/utils/util" + + frpIo "github.com/fatedier/golib/io" ) type ControlManager struct { diff --git a/server/proxy.go b/server/proxy.go index ae211b6b..59477001 100644 --- a/server/proxy.go +++ b/server/proxy.go @@ -27,13 +27,13 @@ import ( "github.com/fatedier/frp/models/config" "github.com/fatedier/frp/models/msg" "github.com/fatedier/frp/models/proto/udp" - frpIo "github.com/fatedier/frp/utils/io" "github.com/fatedier/frp/utils/log" frpNet "github.com/fatedier/frp/utils/net" "github.com/fatedier/frp/utils/util" "github.com/fatedier/frp/utils/vhost" "github.com/fatedier/golib/errors" + frpIo "github.com/fatedier/golib/io" ) type Proxy interface { diff --git a/utils/io/io_test.go b/utils/io/io_test.go deleted file mode 100644 index f12b651b..00000000 --- a/utils/io/io_test.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2017 fatedier, fatedier@gmail.com -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package io - -import ( - "io" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestJoin(t *testing.T) { - assert := assert.New(t) - - var ( - n int - err error - ) - text1 := "A document that gives tips for writing clear, idiomatic Go code. A must read for any new Go programmer. It augments the tour and the language specification, both of which should be read first." - text2 := "A document that specifies the conditions under which reads of a variable in one goroutine can be guaranteed to observe values produced by writes to the same variable in a different goroutine." - - // Forward bytes directly. - pr, pw := io.Pipe() - pr2, pw2 := io.Pipe() - pr3, pw3 := io.Pipe() - pr4, pw4 := io.Pipe() - - conn1 := WrapReadWriteCloser(pr, pw2, nil) - conn2 := WrapReadWriteCloser(pr2, pw, nil) - conn3 := WrapReadWriteCloser(pr3, pw4, nil) - conn4 := WrapReadWriteCloser(pr4, pw3, nil) - - go func() { - Join(conn2, conn3) - }() - - buf1 := make([]byte, 1024) - buf2 := make([]byte, 1024) - - conn1.Write([]byte(text1)) - conn4.Write([]byte(text2)) - - n, err = conn4.Read(buf1) - assert.NoError(err) - assert.Equal(text1, string(buf1[:n])) - - n, err = conn1.Read(buf2) - assert.NoError(err) - assert.Equal(text2, string(buf2[:n])) - - conn1.Close() - conn2.Close() - conn3.Close() - conn4.Close() -} - -func TestWithCompression(t *testing.T) { - assert := assert.New(t) - - // Forward compression bytes. - pr, pw := io.Pipe() - pr2, pw2 := io.Pipe() - - conn1 := WrapReadWriteCloser(pr, pw2, nil) - conn2 := WrapReadWriteCloser(pr2, pw, nil) - - compressionStream1 := WithCompression(conn1) - compressionStream2 := WithCompression(conn2) - - var ( - n int - err error - ) - - text := "1234567812345678" - buf := make([]byte, 256) - - go compressionStream1.Write([]byte(text)) - n, err = compressionStream2.Read(buf) - assert.NoError(err) - assert.Equal(text, string(buf[:n])) - - go compressionStream2.Write([]byte(text)) - n, err = compressionStream1.Read(buf) - assert.NoError(err) - assert.Equal(text, string(buf[:n])) -} - -func TestWithEncryption(t *testing.T) { - assert := assert.New(t) - var ( - n int - err error - ) - text1 := "Go is expressive, concise, clean, and efficient. Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel type system enables flexible and modular program construction. Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It's a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language." - text2 := "An interactive introduction to Go in three sections. The first section covers basic syntax and data structures; the second discusses methods and interfaces; and the third introduces Go's concurrency primitives. Each section concludes with a few exercises so you can practice what you've learned. You can take the tour online or install it locally with" - key := "authkey" - - // Forward enrypted bytes. - pr, pw := io.Pipe() - pr2, pw2 := io.Pipe() - pr3, pw3 := io.Pipe() - pr4, pw4 := io.Pipe() - pr5, pw5 := io.Pipe() - pr6, pw6 := io.Pipe() - - conn1 := WrapReadWriteCloser(pr, pw2, nil) - conn2 := WrapReadWriteCloser(pr2, pw, nil) - conn3 := WrapReadWriteCloser(pr3, pw4, nil) - conn4 := WrapReadWriteCloser(pr4, pw3, nil) - conn5 := WrapReadWriteCloser(pr5, pw6, nil) - conn6 := WrapReadWriteCloser(pr6, pw5, nil) - - encryptStream1, err := WithEncryption(conn3, []byte(key)) - assert.NoError(err) - encryptStream2, err := WithEncryption(conn4, []byte(key)) - assert.NoError(err) - - go Join(conn2, encryptStream1) - go Join(encryptStream2, conn5) - - buf := make([]byte, 1024) - - conn1.Write([]byte(text1)) - conn6.Write([]byte(text2)) - - n, err = conn6.Read(buf) - assert.NoError(err) - assert.Equal(text1, string(buf[:n])) - - n, err = conn1.Read(buf) - assert.NoError(err) -} diff --git a/utils/vhost/reverseproxy.go b/utils/vhost/reverseproxy.go index 365e0f2f..6b0c292b 100644 --- a/utils/vhost/reverseproxy.go +++ b/utils/vhost/reverseproxy.go @@ -17,7 +17,7 @@ import ( "sync" "time" - frpIo "github.com/fatedier/frp/utils/io" + frpIo "github.com/fatedier/golib/io" ) // onExitFlushLoop is a callback set by tests to detect the state of the diff --git a/utils/io/io.go b/vendor/github.com/fatedier/golib/io/io.go similarity index 100% rename from utils/io/io.go rename to vendor/github.com/fatedier/golib/io/io.go