Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
go-mmproxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
go-mmproxy
Commits
45a38020
Unverified
Commit
45a38020
authored
5 years ago
by
Konrad Zemek
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2 from onlyjob/master
codespell: spelling corrections
parents
52daf519
d1904f37
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+2
-2
2 additions, 2 deletions
README.md
main.go
+2
-2
2 additions, 2 deletions
main.go
tcp.go
+4
-4
4 additions, 4 deletions
tcp.go
with
8 additions
and
8 deletions
README.md
+
2
−
2
View file @
45a38020
...
@@ -58,7 +58,7 @@ Usage of ./go-mmproxy:
...
@@ -58,7 +58,7 @@ Usage of ./go-mmproxy:
-close-after int
-close-after int
Number of seconds after which UDP socket will be cleaned up (default 60)
Number of seconds after which UDP socket will be cleaned up (default 60)
-l string
-l string
Adress the proxy listens on (default "0.0.0.0:8443")
Ad
d
ress the proxy listens on (default "0.0.0.0:8443")
-listeners int
-listeners int
Number of listener sockets that will be opened for the listen address (Linux 3.9+) (default 1)
Number of listener sockets that will be opened for the listen address (Linux 3.9+) (default 1)
-mark int
-mark int
...
@@ -67,7 +67,7 @@ Usage of ./go-mmproxy:
...
@@ -67,7 +67,7 @@ Usage of ./go-mmproxy:
Protocol that will be proxied: tcp, udp (default "tcp")
Protocol that will be proxied: tcp, udp (default "tcp")
-v int
-v int
0 - no logging of individual connections
0 - no logging of individual connections
1 - log errors occuring in individual connections
1 - log errors occur
r
ing in individual connections
2 - log all state changes of individual connections
2 - log all state changes of individual connections
```
```
...
...
This diff is collapsed.
Click to expand it.
main.go
+
2
−
2
View file @
45a38020
...
@@ -35,12 +35,12 @@ var Opts options
...
@@ -35,12 +35,12 @@ var Opts options
func
init
()
{
func
init
()
{
flag
.
StringVar
(
&
Opts
.
Protocol
,
"p"
,
"tcp"
,
"Protocol that will be proxied: tcp, udp"
)
flag
.
StringVar
(
&
Opts
.
Protocol
,
"p"
,
"tcp"
,
"Protocol that will be proxied: tcp, udp"
)
flag
.
StringVar
(
&
Opts
.
ListenAddr
,
"l"
,
"0.0.0.0:8443"
,
"Adress the proxy listens on"
)
flag
.
StringVar
(
&
Opts
.
ListenAddr
,
"l"
,
"0.0.0.0:8443"
,
"Ad
d
ress the proxy listens on"
)
flag
.
StringVar
(
&
Opts
.
TargetAddr4
,
"4"
,
"127.0.0.1:443"
,
"Address to which IPv4 traffic will be forwarded to"
)
flag
.
StringVar
(
&
Opts
.
TargetAddr4
,
"4"
,
"127.0.0.1:443"
,
"Address to which IPv4 traffic will be forwarded to"
)
flag
.
StringVar
(
&
Opts
.
TargetAddr6
,
"6"
,
"[::1]:443"
,
"Address to which IPv6 traffic will be forwarded to"
)
flag
.
StringVar
(
&
Opts
.
TargetAddr6
,
"6"
,
"[::1]:443"
,
"Address to which IPv6 traffic will be forwarded to"
)
flag
.
IntVar
(
&
Opts
.
Mark
,
"mark"
,
0
,
"The mark that will be set on outbound packets"
)
flag
.
IntVar
(
&
Opts
.
Mark
,
"mark"
,
0
,
"The mark that will be set on outbound packets"
)
flag
.
IntVar
(
&
Opts
.
Verbose
,
"v"
,
0
,
`0 - no logging of individual connections
flag
.
IntVar
(
&
Opts
.
Verbose
,
"v"
,
0
,
`0 - no logging of individual connections
1 - log errors occuring in individual connections
1 - log errors occur
r
ing in individual connections
2 - log all state changes of individual connections`
)
2 - log all state changes of individual connections`
)
flag
.
StringVar
(
&
Opts
.
allowedSubnetsPath
,
"allowed-subnets"
,
""
,
flag
.
StringVar
(
&
Opts
.
allowedSubnetsPath
,
"allowed-subnets"
,
""
,
"Path to a file that contains allowed subnets of the proxy servers"
)
"Path to a file that contains allowed subnets of the proxy servers"
)
...
...
This diff is collapsed.
Click to expand it.
tcp.go
+
4
−
4
View file @
45a38020
...
@@ -57,7 +57,7 @@ func tcpHandleConnection(conn net.Conn, logger *zap.Logger) {
...
@@ -57,7 +57,7 @@ func tcpHandleConnection(conn net.Conn, logger *zap.Logger) {
logger
=
logger
.
With
(
zap
.
String
(
"clientAddr"
,
saddr
.
String
()),
zap
.
String
(
"targetAddr"
,
targetAddr
))
logger
=
logger
.
With
(
zap
.
String
(
"clientAddr"
,
saddr
.
String
()),
zap
.
String
(
"targetAddr"
,
targetAddr
))
if
Opts
.
Verbose
>
1
{
if
Opts
.
Verbose
>
1
{
logger
.
Debug
(
"successfuly parsed PROXY header"
)
logger
.
Debug
(
"successful
l
y parsed PROXY header"
)
}
}
dialer
:=
net
.
Dialer
{
LocalAddr
:
saddr
}
dialer
:=
net
.
Dialer
{
LocalAddr
:
saddr
}
...
@@ -72,19 +72,19 @@ func tcpHandleConnection(conn net.Conn, logger *zap.Logger) {
...
@@ -72,19 +72,19 @@ func tcpHandleConnection(conn net.Conn, logger *zap.Logger) {
defer
upstreamConn
.
Close
()
defer
upstreamConn
.
Close
()
if
Opts
.
Verbose
>
1
{
if
Opts
.
Verbose
>
1
{
logger
.
Debug
(
"successfuly established upstream connection"
)
logger
.
Debug
(
"successful
l
y established upstream connection"
)
}
}
if
err
:=
conn
.
(
*
net
.
TCPConn
)
.
SetNoDelay
(
true
);
err
!=
nil
{
if
err
:=
conn
.
(
*
net
.
TCPConn
)
.
SetNoDelay
(
true
);
err
!=
nil
{
logger
.
Debug
(
"failed to set nodelay on downstream connection"
,
zap
.
Error
(
err
),
zap
.
Bool
(
"dropConnection"
,
true
))
logger
.
Debug
(
"failed to set nodelay on downstream connection"
,
zap
.
Error
(
err
),
zap
.
Bool
(
"dropConnection"
,
true
))
}
else
if
Opts
.
Verbose
>
1
{
}
else
if
Opts
.
Verbose
>
1
{
logger
.
Debug
(
"successfuly set NoDelay on downstream connection"
)
logger
.
Debug
(
"successful
l
y set NoDelay on downstream connection"
)
}
}
if
err
:=
upstreamConn
.
(
*
net
.
TCPConn
)
.
SetNoDelay
(
true
);
err
!=
nil
{
if
err
:=
upstreamConn
.
(
*
net
.
TCPConn
)
.
SetNoDelay
(
true
);
err
!=
nil
{
logger
.
Debug
(
"failed to set nodelay on upstream connection"
,
zap
.
Error
(
err
),
zap
.
Bool
(
"dropConnection"
,
true
))
logger
.
Debug
(
"failed to set nodelay on upstream connection"
,
zap
.
Error
(
err
),
zap
.
Bool
(
"dropConnection"
,
true
))
}
else
if
Opts
.
Verbose
>
1
{
}
else
if
Opts
.
Verbose
>
1
{
logger
.
Debug
(
"successfuly set NoDelay on upstream connection"
)
logger
.
Debug
(
"successful
l
y set NoDelay on upstream connection"
)
}
}
for
len
(
restBytes
)
>
0
{
for
len
(
restBytes
)
>
0
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment