Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
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
nanahira
ygopro
Commits
e1ee08b2
Commit
e1ee08b2
authored
Sep 24, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update ParseHost
parent
87a502d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
19 deletions
+37
-19
gframe/duelclient.cpp
gframe/duelclient.cpp
+35
-18
gframe/duelclient.h
gframe/duelclient.h
+2
-1
No files found.
gframe/duelclient.cpp
View file @
e1ee08b2
...
...
@@ -4147,35 +4147,52 @@ bool DuelClient::LookupSRV(char *hostname, HostResult* result) {
return
true
;
}
bool
DuelClient
::
CheckHostnameSplitter
(
char
*
hostname
,
HostResult
*
result
)
{
auto
trySplitter
=
strchr
(
hostname
,
':'
);
if
(
trySplitter
==
NULL
)
return
false
;
char
host
[
100
];
auto
hostLength
=
trySplitter
-
hostname
;
strncpy
(
host
,
hostname
,
hostLength
);
host
[
hostLength
]
=
'\0'
;
result
.
host
=
LookupHost
(
host
);
result
.
port
=
atoi
(
trySplitter
+
1
);
return
true
;
}
HostResult
DuelClient
::
ParseHost
(
char
*
hostname
,
unsigned
short
port
)
{
HostResult
result
;
// if port found, use port directly
if
(
port
)
{
result
.
host
=
LookupHost
(
hostname
);
result
.
port
=
port
;
// if hostname contains splitter, use port after splitter in priority
if
(
!
CheckHostnameSplitter
(
hostname
,
&
result
))
{
result
.
host
=
LookupHost
(
hostname
);
result
.
port
=
port
;
}
return
result
;
}
// if hostname is an IP, use it directly and use default port
unsigned
int
tryAddress
=
htonl
(
inet_addr
(
hostname
));
if
(
tryAddress
!=
-
1
)
{
result
.
host
=
tryAddress
;
result
.
port
=
7911
;
return
result
;
}
auto
trySplitter
=
strchr
(
hostname
,
':'
);
if
(
trySplitter
==
NULL
)
{
char
srvHostname
[
114
];
sprintf
(
srvHostname
,
"_ygopro._tcp.%s"
,
hostname
);
if
(
!
LookupSRV
(
srvHostname
,
&
result
))
{
result
.
host
=
LookupHost
(
hostname
);
result
.
port
=
7911
;
}
}
else
{
char
host
[
100
];
auto
hostLength
=
trySplitter
-
hostname
;
strncpy
(
host
,
hostname
,
hostLength
);
host
[
hostLength
]
=
'\0'
;
result
.
host
=
LookupHost
(
host
);
result
.
port
=
atoi
(
trySplitter
+
1
);
}
// if hostname contains splitter, use it first
if
(
CheckHostnameSplitter
(
hostname
,
&
result
))
return
result
;
// lookup SRV record
char
srvHostname
[
114
];
sprintf
(
srvHostname
,
"_ygopro._tcp.%s"
,
hostname
);
if
(
LookupSRV
(
srvHostname
,
&
result
))
return
result
;
// finally, use default port
result
.
host
=
LookupHost
(
hostname
);
result
.
port
=
7911
;
return
result
;
}
}
gframe/duelclient.h
View file @
e1ee08b2
...
...
@@ -91,7 +91,8 @@ public:
static
void
SetResponseB
(
void
*
respB
,
unsigned
char
len
);
static
void
SendResponse
();
static
unsigned
int
LookupHost
(
char
*
host
);
static
bool
LookupSRV
(
char
*
hostname
,
HostResult
*
result
);
static
bool
LookupSRV
(
char
*
hostname
,
HostResult
*
result
);
static
bool
CheckHostnameSplitter
(
char
*
hostname
,
HostResult
*
result
)
static
HostResult
ParseHost
(
char
*
hostname
,
unsigned
short
port
);
static
void
SendPacketToServer
(
unsigned
char
proto
)
{
char
*
p
=
duel_client_write
;
...
...
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