Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
majora-go
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
majora
majora-go
Commits
c4e44e4c
Commit
c4e44e4c
authored
Jan 15, 2022
by
Tsaiilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重播问题修复
parent
7a5a79cb
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
22 deletions
+37
-22
cluster.go
client/cluster.go
+23
-11
event.go
client/event.go
+4
-3
getty.go
client/getty.go
+0
-2
common.go
common/common.go
+3
-3
majora-dev.yaml
conf/majora-dev.yaml
+2
-2
majora.yaml
conf/majora.yaml
+1
-1
redail.go
infra/redail.go
+4
-0
No files found.
client/cluster.go
View file @
c4e44e4c
...
...
@@ -5,6 +5,7 @@ import (
"net"
"sync"
"time"
"virjar.com/majora-go/common"
"gopkg.in/fatih/set.v0"
...
...
@@ -107,6 +108,7 @@ func (c *ClusterClient) StartRedial(tag string, replay bool) {
defer
func
(
startTime
time
.
Time
)
{
log
.
Run
()
.
Infof
(
"StartRedial cost %v"
,
time
.
Since
(
startTime
))
}(
time
.
Now
())
if
c
.
Redial
.
CanRedial
()
{
if
replay
{
c
.
clients
.
Range
(
func
(
host
,
c
interface
{})
bool
{
client
,
_
:=
c
.
(
*
Client
)
...
...
@@ -115,14 +117,24 @@ func (c *ClusterClient) StartRedial(tag string, replay bool) {
})
time
.
Sleep
(
global
.
Config
.
Redial
.
WaitTime
)
}
c
.
Redial
.
Redial
(
tag
)
log
.
Run
()
.
Info
(
"[Redial %s ] start close local session"
,
tag
)
c
.
clients
.
Range
(
func
(
host
,
c
interface
{})
bool
{
client
,
_
:=
c
.
(
*
Client
)
client
.
CloseAll
()
client
.
natTunnel
.
Close
()
return
true
})
c
.
Redial
.
Redial
(
tag
)
//client.natTunnel.Close 的实现不是立即生效,需要等待读写超时
time
.
Sleep
(
common
.
ReadTimeout
)
c
.
clients
.
Range
(
func
(
host
,
c
interface
{})
bool
{
client
,
_
:=
c
.
(
*
Client
)
client
.
connect
()
return
true
})
}
else
{
log
.
Run
()
.
Info
(
"inRedialing ignore"
)
}
}
...
...
client/event.go
View file @
c4e44e4c
...
...
@@ -177,10 +177,11 @@ func (client *Client) handleTransfer(packet *protocol.MajoraPacket, session gett
}
func
(
client
*
Client
)
handleDisconnectMessage
(
session
getty
.
Session
,
packet
*
protocol
.
MajoraPacket
)
{
log
.
Run
()
.
Debugf
(
"[handleDisconnectMessage] %d->session closed %v extra:%s"
,
packet
.
SerialNumber
,
session
.
IsClosed
())
log
.
Run
()
.
Debugf
(
"[handleDisconnectMessage] %d->session closed %v extra:%s"
,
packet
.
SerialNumber
,
session
.
IsClosed
(),
packet
.
Extra
)
// disconnect 会多回复一个关闭的包,暂时忽略,后续更改关闭交互流程
t
,
ok
:=
client
.
GetTransfer
(
packet
.
SerialNumber
)
if
!
ok
{
log
.
Error
()
.
Errorf
(
"handleDisconnectMessage can't find transfer"
)
log
.
Run
()
.
Debug
(
"handleDisconnectMessage can't find transfer"
)
return
}
t
.
Close
()
...
...
@@ -210,7 +211,6 @@ func (client *Client) GetRecorder(sn int64) trace.Recorder {
func
(
client
*
Client
)
GetTransfer
(
sn
int64
)
(
*
Transfer
,
bool
)
{
t
,
ok
:=
client
.
transferStore
.
Load
(
sn
)
if
!
ok
{
log
.
Error
()
.
Errorf
(
"[GetTransfer] error, not exist (sn:%d)"
,
sn
)
return
nil
,
false
}
transfer
:=
t
.
(
*
Transfer
)
...
...
@@ -220,6 +220,7 @@ func (client *Client) GetTransfer(sn int64) (*Transfer, bool) {
func
(
client
*
Client
)
AddTransfer
(
sn
int64
,
transfer
*
Transfer
,
addr
string
)
{
if
_
,
ok
:=
client
.
transferStore
.
Load
(
sn
);
ok
{
log
.
Error
()
.
Errorf
(
"[AddTransfer] %d->error, has one"
,
sn
)
return
}
client
.
transferStore
.
Store
(
sn
,
transfer
)
log
.
Run
()
.
Debugf
(
"[AddTransfer] %d->%s success"
,
sn
,
addr
)
...
...
client/getty.go
View file @
c4e44e4c
...
...
@@ -78,6 +78,4 @@ func (client *Client) Redial(tag string) {
if
_
,
_
,
err
:=
client
.
session
.
WritePkg
(
OfflinePacket
,
0
);
err
!=
nil
{
log
.
Run
()
.
Errorf
(
"[Redial %s] write offline to server error %s"
,
tag
,
err
.
Error
())
}
log
.
Run
()
.
Info
(
"[Redial %s %s] start close local session"
,
client
.
host
,
tag
)
}
common/common.go
View file @
c4e44e4c
...
...
@@ -45,9 +45,9 @@ const (
)
const
(
ReadTimeout
=
time
.
Minute
WriteTimeout
=
time
.
Minute
WaitTimeout
=
time
.
Minute
ReadTimeout
=
30
*
time
.
Second
WriteTimeout
=
30
*
time
.
Second
WaitTimeout
=
30
*
time
.
Second
KeepAliveTimeout
=
time
.
Second
*
10
SessionTimeout
=
time
.
Minute
*
5
...
...
conf/majora-dev.yaml
View file @
c4e44e4c
tunnel_addr
:
127.0.0.1:5879
dns_server
:
114.114.114.114:53
#daemon: true
log_level
:
debug
log_level
:
info
log_path
:
./majora-log/
reconn_intervalz
:
5s
net_check_interval
:
5s
dns_cache_duration
:
10m
net_check_url
:
https://www.baidu.com
[extra]
net_check_url
:
https://www.baidu.com
#redial:
# command: /bin/bash
...
...
conf/majora.yaml
View file @
c4e44e4c
tunnel_addr
:
majora-vps
-zj
.virjar.com:5879
tunnel_addr
:
majora-vps.virjar.com:5879
dns_server
:
114.114.114.114:53
log_level
:
info
log_path
:
./majora-log/
...
...
infra/redail.go
View file @
c4e44e4c
...
...
@@ -26,6 +26,10 @@ func NewPPPRedial() *PPPRedial {
}
}
func
(
p
*
PPPRedial
)
CanRedial
()
bool
{
return
!
p
.
inRedialing
.
Load
()
}
func
(
p
*
PPPRedial
)
Redial
(
tag
string
)
bool
{
if
p
.
inRedialing
.
CAS
(
false
,
true
)
{
log
.
Run
()
.
Infof
(
"[PPPRedial %s] start"
,
tag
)
...
...
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