Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
maotama-server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
maotama-server
Commits
64e0c8a8
Commit
64e0c8a8
authored
Sep 30, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
66cb6bd3
Pipeline
#840
passed with stage
in 4 minutes and 13 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
main.go
main.go
+10
-5
No files found.
main.go
View file @
64e0c8a8
...
...
@@ -110,7 +110,9 @@ func transferHostTrafficToGuest(host *net.UDPConn, guest *net.UDPConn, guestAddr
log
.
Println
(
"Host read error: "
,
guestAddr
.
String
(),
err
)
break
}
guest
.
WriteToUDP
(
buffer
[
:
length
],
guestAddr
)
data
:=
buffer
[
:
length
]
translateHostToGuestPackets
(
&
data
,
length
,
htogAddressTranslateList
)
guest
.
WriteToUDP
(
data
,
guestAddr
)
}
(
*
htogAddressTranslateList
)[
hostRemoteAddr
.
String
()]
=
nil
}
...
...
@@ -123,7 +125,9 @@ func transferGuestTrafficToHost(host *net.UDPConn, hostAddr *net.UDPAddr, guestA
exit
=
true
break
}
else
{
host
.
WriteToUDP
(
message
.
data
,
hostAddr
)
data
:=
message
.
data
translateHostToGuestPackets
(
&
data
,
message
.
length
,
gtohAddressTranslateList
)
host
.
WriteToUDP
(
data
,
hostAddr
)
}
case
<-
time
.
After
(
time
.
Duration
(
2
)
*
time
.
Minute
)
:
log
.
Println
(
"Guest timeout: "
,
guestAddr
.
String
(),
hostAddr
.
String
())
...
...
@@ -139,8 +143,9 @@ func transferGuestTrafficToHost(host *net.UDPConn, hostAddr *net.UDPAddr, guestA
}
type
GuestToHostMessage
struct
{
exit
bool
data
[]
byte
exit
bool
data
[]
byte
length
int
}
func
listenUDP
(
ws
*
websocket
.
Conn
)
{
...
...
@@ -202,7 +207,7 @@ func listenUDP(ws *websocket.Conn) {
guestChannelList
[
guestAddr
.
String
()]
=
channel
go
transferGuestTrafficToHost
(
host
,
hostAddr
,
guestAddr
,
channel
,
&
guestChannelList
,
&
gtohAddressTranslateList
)
}
else
{
msg
:=
GuestToHostMessage
{
data
:
message
[
:
length
],
exit
:
false
}
msg
:=
GuestToHostMessage
{
data
:
message
[
:
length
],
length
:
length
,
exit
:
false
}
channel
<-
msg
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment