-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from shoriwe/Project-Structure
Project structure
- Loading branch information
Showing
58 changed files
with
1,129 additions
and
857 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
.idea/modules.xml | ||
.idea/misc.xml | ||
.idea/FullProxy.iml | ||
build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/shoriwe/FullProxy/internal/ArgumentParser" | ||
"github.com/shoriwe/FullProxy/internal/ProxiesSetup" | ||
"github.com/shoriwe/FullProxy/internal/SetupControllers" | ||
"os" | ||
) | ||
|
||
func main() { | ||
numberOfArguments := len(os.Args) | ||
if numberOfArguments == 1 { | ||
_, _ = fmt.Fprintln(os.Stderr, "Try:\n", os.Args[0], " help") | ||
os.Exit(-1) | ||
} | ||
switch os.Args[1] { | ||
case "socks5": | ||
host, port, username, password, slave := ArgumentParser.ParseSocks5Arguments() | ||
ProxiesSetup.SetupSocks5(host, port, slave, username, password) | ||
case "http": | ||
host, port, username, password, slave, tls := ArgumentParser.HTTPArguments() | ||
ProxiesSetup.SetupHTTP(host, port, slave, tls, username, password) | ||
case "local-forward": | ||
host, port, masterHost, masterPort := ArgumentParser.LocalPortForwardArguments() | ||
ProxiesSetup.SetupLocalForward(host, port, masterHost, masterPort) | ||
case "remote-forward": | ||
localHost, localPort, masterHost, masterPort := ArgumentParser.RemotePortForwardArguments() | ||
ProxiesSetup.SetupRemoteForward(localHost, localPort, masterHost, masterPort) | ||
case "master": | ||
masterHost, masterPort, remoteHost, remotePort := ArgumentParser.ParseMasterArguments() | ||
if len(*remoteHost) > 0 && len(*remotePort) > 0 { | ||
SetupControllers.MasterRemote(masterHost, masterPort, remoteHost, remotePort) | ||
} else { | ||
SetupControllers.MasterGeneral(masterHost, masterPort) | ||
} | ||
case "translate": | ||
if numberOfArguments == 2 { | ||
_, _ = fmt.Fprintln(os.Stderr, "Try:\n", os.Args[0], " translate help") | ||
os.Exit(-1) | ||
} | ||
switch os.Args[2] { | ||
case "port_forward-socks5": | ||
bindHost, bindPort, socks5Host, socks5Port, username, password, targetHost, targetPort := ArgumentParser.ParseForwardToSocks5Arguments() | ||
ProxiesSetup.SetupForwardSocks5(bindHost, bindPort, socks5Host, socks5Port, username, password, targetHost, targetPort) | ||
case "help": | ||
ArgumentParser.ShowTranslateHelpMessage() | ||
default: | ||
_, _ = fmt.Fprintln(os.Stderr, "Unknown command\nTry: ", os.Args[0], " translate help") | ||
os.Exit(-1) | ||
} | ||
case "help": | ||
ArgumentParser.ShowGeneralHelpMessage() | ||
default: | ||
_, _ = fmt.Fprintln(os.Stderr, "Unknown command\nTry: ", os.Args[0], " help") | ||
os.Exit(-1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ProxiesSetup | ||
|
||
import ( | ||
"bytes" | ||
"github.com/shoriwe/FullProxy/pkg/ConnectionControllers" | ||
) | ||
|
||
func BasicAuthentication(username []byte, password []byte) ConnectionControllers.AuthenticationMethod { | ||
return func(clientUsername []byte, clientPassword []byte) bool { | ||
return bytes.Equal(username, clientUsername) && bytes.Equal(password, clientPassword) | ||
} | ||
} | ||
|
||
func NoAuthentication(_ []byte, _ []byte) bool { | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ProxiesSetup | ||
|
||
import ( | ||
"github.com/shoriwe/FullProxy/internal/SetupControllers" | ||
"github.com/shoriwe/FullProxy/pkg/Proxies/Translation/ForwardToSocks5" | ||
"golang.org/x/net/proxy" | ||
"log" | ||
) | ||
|
||
func SetupForwardSocks5( | ||
bindHost *string, bindPort *string, | ||
socks5Host *string, socks5Port *string, | ||
username *string, password *string, | ||
targetHost *string, targetPort *string) { | ||
proxyProtocol := new(ForwardToSocks5.ForwardToSocks5) | ||
proxyProtocol.TargetHost = *targetHost | ||
proxyProtocol.TargetPort = *targetPort | ||
proxyAuth := new(proxy.Auth) | ||
if len(*username) > 0 && len(*password) > 0 { | ||
proxyAuth.User = *username | ||
proxyAuth.Password = *password | ||
} else { | ||
proxyAuth = nil | ||
} | ||
proxyDialer, dialerCreationError := proxy.SOCKS5("tcp", *socks5Host+":"+*socks5Port, proxyAuth, proxy.Direct) | ||
if dialerCreationError != nil { | ||
log.Fatal(dialerCreationError) | ||
} | ||
proxyProtocol.Socks5Dialer = proxyDialer | ||
SetupControllers.Bind(bindHost, bindPort, proxyProtocol) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ProxiesSetup | ||
|
||
import ( | ||
"github.com/shoriwe/FullProxy/internal/SetupControllers" | ||
"github.com/shoriwe/FullProxy/pkg/Proxies/HTTP" | ||
"gopkg.in/elazarl/goproxy.v1" | ||
) | ||
|
||
func SetupHTTP(host *string, port *string, slave *bool, tls *bool, username []byte, password []byte) { | ||
proxy := new(HTTP.HTTP) | ||
proxyController := goproxy.NewProxyHttpServer() | ||
proxy.ProxyController = proxyController | ||
if len(username) > 0 && len(password) > 0 { | ||
proxy.SetAuthenticationMethod(BasicAuthentication(username, password)) | ||
} | ||
if *slave { | ||
SetupControllers.GeneralSlave(host, port, proxy) | ||
} else { | ||
SetupControllers.Bind(host, port, proxy) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ProxiesSetup | ||
|
||
import ( | ||
"github.com/shoriwe/FullProxy/internal/SetupControllers" | ||
"github.com/shoriwe/FullProxy/pkg/Proxies/PortForward" | ||
) | ||
|
||
func SetupLocalForward(host *string, port *string, masterHost *string, masterPort *string) { | ||
proxy := new(PortForward.LocalForward) | ||
proxy.TargetHost = *host | ||
proxy.TargetPort = *port | ||
SetupControllers.GeneralSlave(masterHost, masterPort, proxy) | ||
} |
Oops, something went wrong.