Version 1.0 alpha

This commit is contained in:
V2Ray committed 2015-09-12 20:36:21 +02:00
1 parent f3a12e9f57
commit cc3fdb6ef4
21 files changed
+279 -103

No files matched your search

+9 -7
View File
@@ -2,10 +2,10 @@ package freedom
import (
"io"
"log"
"net"
"github.com/v2ray/v2ray-core"
"github.com/v2ray/v2ray-core/log"
v2net "github.com/v2ray/v2ray-core/net"
)
@@ -24,10 +24,9 @@ func (vconn *VFreeConnection) Start(vRay core.OutboundVRay) error {
output := vRay.OutboundOutput()
conn, err := net.Dial("tcp", vconn.dest.String())
if err != nil {
log.Print(err)
return err
return log.Error("Failed to open tcp: %s", vconn.dest.String())
}
log.Print("Working on tcp:" + vconn.dest.String())
log.Debug("Sending outbound tcp: %s", vconn.dest.String())
finish := make(chan bool, 2)
go vconn.DumpInput(conn, input, finish)
@@ -41,22 +40,25 @@ func (vconn *VFreeConnection) DumpInput(conn net.Conn, input <-chan []byte, fini
data, open := <-input
if !open {
finish <- true
log.Debug("Freedom finishing input.")
break
}
conn.Write(data)
nBytes, err := conn.Write(data)
log.Debug("Freedom wrote %d bytes with error %v", nBytes, err)
}
}
func (vconn *VFreeConnection) DumpOutput(conn net.Conn, output chan<- []byte, finish chan<- bool) {
for {
buffer := make([]byte, 128)
buffer := make([]byte, 512)
nBytes, err := conn.Read(buffer)
log.Debug("Freedom reading %d bytes with error %v", nBytes, err)
if err == io.EOF {
close(output)
finish <- true
log.Debug("Freedom finishing output.")
break
}
log.Print(buffer[:nBytes])
output <- buffer[:nBytes]
}
}
+4
View File
@@ -11,3 +11,7 @@ type FreedomFactory struct {
func (factory FreedomFactory) Create(vp *core.VPoint, config []byte, dest v2net.VAddress) (core.OutboundConnectionHandler, error) {
return NewVFreeConnection(dest), nil
}
func init() {
core.RegisterOutboundConnectionHandlerFactory("freedom", FreedomFactory{})
}