Giter VIP home page Giter VIP logo

gole's People

Contributors

shawwwn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gole's Issues

Simplified code at one location.

Gole/server.go

Lines 240 to 278 in 5115deb

go func() {
defer conn.Close()
defer fwd_conn.Close()
buf := make([]byte, 4096)
for {
conn.SetDeadline(time.Now().Add(time.Duration(g_timeout) * time.Second))
n, _, err := conn.ReadFrom(buf)
if err != nil {
fmt.Println("conn.Read() failed.", err)
return
}
_, err = fwd_conn.Write(buf[:n])
if err != nil {
fmt.Println("fwd_conn.Write() failed.", err)
return
}
}
}()
// fwd_conn --> conn
func() {
defer conn.Close()
defer fwd_conn.Close()
buf := make([]byte, 4096)
for {
n, err := fwd_conn.Read(buf)
if err != nil {
fmt.Println("fwd_conn.Read() failed.", err)
return
}
_, err = conn.WriteTo(buf[:n], conf.RAddr)
if err != nil {
fmt.Println("conn.Write() failed.", err)
return
}
conn.SetDeadline(time.Now().Add(time.Duration(g_timeout) * time.Second))
}
}()

The code snippet seems replaceable with io.copy directly.

// Copy copies from src to dst until either EOF is reached
// on src or an error occurs. It returns the number of bytes
// copied and the first error encountered while copying, if any.
//
// A successful Copy returns err == nil, not err == EOF.
// Because Copy is defined to read from src until EOF, it does
// not treat an EOF from Read as an error to be reported.
//
// If src implements the WriterTo interface,
// the copy is implemented by calling src.WriteTo(dst).
// Otherwise, if dst implements the ReaderFrom interface,
// the copy is implemented by calling dst.ReadFrom(src).
func Copy(dst Writer, src Reader) (written int64, err error) {
	return copyBuffer(dst, src, nil)
}

Write like:

func Forward(local *net.TCPConn, remote *net.TCPConn) {
	f := func(src *net.TCPConn, dst *net.TCPConn) {
		defer src.Close()
		defer dst.Close()
		_, err := io.Copy(src, dst)
		if err != nil {
			log.errorf("Fail to copy from src to dst, err=%v", err)
			return
		}
	}
	go f(local, remote)
	go f(remote, local)
}

how does gole work

not really an issue but i am wondering how does gole work without an external server? I thought you absolutely need a server which can actually forward ports and is globally accessible.
is it what server option is for? lets say i am trying to play a p2p game and both players need to know each other's ip and both are behind NAT and cannot forward ports.
how would i do that?

how does gole work?

I try to drill a hole as follows
./gole -v tcp 0.0.0.0:3333 112.49.232.96:4444 -op server -fwd=127.0.0.1:8080
./gole -v tcp 0.0.0.0:4444 223.104.51.140:4444 -op client -fwd=127.0.0.1:1111
But it seems unlikely to succeed:
1705046125565
What should I do?

One-to-Many solution

Hello..

first of all. thank you for this amazing project.
however, I have a question/problem?

what if we don't know the "client" public ip address? is there a way to use the tunnel for the sole purpose of port forwarding between point A and point B? so Point A has a static configuration and point B only needs to know point A's public ip and port?

ovpn?

Can this work with openvpn?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.