Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
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
wei.xuan
getty
Commits
493e5afc
Commit
493e5afc
authored
Sep 12, 2016
by
alexstocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
defeat self connection
parent
807e92dc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
2 deletions
+19
-2
README.md
README.md
+7
-0
client.go
client.go
+3
-0
server.go
server.go
+8
-1
version.go
version.go
+1
-1
No files found.
README.md
View file @
493e5afc
...
@@ -10,6 +10,13 @@
...
@@ -10,6 +10,13 @@
## develop history ##
## develop history ##
---
---
-
2016/09/09
> 1 add defeat self connection logic in client.go & server.go
>
> 2 version: 0.3.08
-
2016/09/09
-
2016/09/09
> 1 delete session.go:(Session)readerDone
> 1 delete session.go:(Session)readerDone
>
>
...
...
client.go
View file @
493e5afc
...
@@ -73,6 +73,9 @@ func (this *Client) dial() net.Conn {
...
@@ -73,6 +73,9 @@ func (this *Client) dial() net.Conn {
return
nil
return
nil
}
}
conn
,
err
=
net
.
DialTimeout
(
"tcp"
,
this
.
addr
,
connectTimeout
)
conn
,
err
=
net
.
DialTimeout
(
"tcp"
,
this
.
addr
,
connectTimeout
)
if
err
==
nil
&&
conn
.
LocalAddr
()
.
String
()
==
conn
.
RemoteAddr
()
.
String
()
{
err
=
errSelfConnect
}
if
err
==
nil
{
if
err
==
nil
{
return
conn
return
conn
}
}
...
...
server.go
View file @
493e5afc
...
@@ -20,6 +20,10 @@ import (
...
@@ -20,6 +20,10 @@ import (
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
)
)
var
(
errSelfConnect
=
errors
.
New
(
"connect self!"
)
)
type
Server
struct
{
type
Server
struct
{
// net
// net
addr
string
addr
string
...
@@ -107,7 +111,7 @@ func (this *Server) RunEventloop(newSession NewSessionCallback) {
...
@@ -107,7 +111,7 @@ func (this *Server) RunEventloop(newSession NewSessionCallback) {
}
}
continue
continue
}
}
log
.
Info
(
"Server{%s}.Accept() = err {%#v}"
,
this
.
addr
,
err
)
log
.
Warn
(
"Server{%s}.Accept() = err {%#v}"
,
this
.
addr
,
err
)
continue
continue
}
}
delay
=
0
delay
=
0
...
@@ -125,6 +129,9 @@ func (this *Server) Accept(newSession NewSessionCallback) (*Session, error) {
...
@@ -125,6 +129,9 @@ func (this *Server) Accept(newSession NewSessionCallback) (*Session, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
conn
.
RemoteAddr
()
.
String
()
==
conn
.
LocalAddr
()
.
String
()
{
return
nil
,
errSelfConnect
}
session
:=
NewSession
(
conn
)
session
:=
NewSession
(
conn
)
err
=
newSession
(
session
)
err
=
newSession
(
session
)
...
...
version.go
View file @
493e5afc
...
@@ -10,5 +10,5 @@
...
@@ -10,5 +10,5 @@
package
getty
package
getty
var
(
var
(
Version
=
"0.3.0
7
"
Version
=
"0.3.0
8
"
)
)
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