Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-match
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
ygopro-match
Commits
879f9ef4
Commit
879f9ef4
authored
Jan 30, 2016
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix and docker
parent
624aaed2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
22 deletions
+44
-22
Dockerfile
Dockerfile
+7
-0
main.js
main.js
+37
-22
No files found.
Dockerfile
0 → 100644
View file @
879f9ef4
FROM
node
RUN
mkdir
-p
/usr/src/app
WORKDIR
/usr/src/app
#COPY package.json /usr/src/app/
#RUN npm install
COPY
. /usr/src/app
CMD
[ "npm", "start" ]
main.js
View file @
879f9ef4
/**
'
use strict
'
;
* Created by zh99998 on 16/1/25.
*/
const
http
=
require
(
'
http
'
);
const
http
=
require
(
'
http
'
);
const
crypto
=
require
(
'
crypto
'
);
const
crypto
=
require
(
'
crypto
'
);
// Create an HTTP tunneling proxy
let
servers
=
[{
var
servers
=
[{
"
address
"
:
"
122.0.65.73
"
,
"
address
"
:
"
122.0.65.73
"
,
"
port
"
:
233
"
port
"
:
7911
}];
}];
var
pending
=
null
;
let
pending
=
null
;
http
.
createServer
((
req
,
res
)
=>
{
http
.
createServer
((
req
,
res
)
=>
{
try
{
try
{
var
credentials
=
new
Buffer
(
req
.
headers
[
'
authorization
'
].
split
(
'
'
)[
1
],
'
base64
'
).
toString
().
split
(
'
:
'
);
let
credentials
=
new
Buffer
(
req
.
headers
[
'
authorization
'
].
split
(
'
'
)[
1
],
'
base64
'
).
toString
().
split
(
'
:
'
);
var
username
=
credentials
[
0
];
let
username
=
credentials
[
0
];
var
password
=
credentials
[
1
];
let
password
=
credentials
[
1
];
if
(
!
username
||
!
password
)
{
if
(
!
username
||
!
password
)
{
throw
'
auth
'
;
throw
'
auth
'
;
}
}
//TODO: Auth
//TODO: Auth
console
.
log
(
username
+
'
requested match.
'
);
console
.
log
(
username
+
'
requested match.
'
);
res
.
username
=
username
;
res
.
password
=
password
;
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
statusCode
=
403
;
res
.
statusCode
=
403
;
res
.
end
();
res
.
end
();
...
@@ -29,27 +28,43 @@ http.createServer((req, res) => {
...
@@ -29,27 +28,43 @@ http.createServer((req, res) => {
}
}
if
(
pending
)
{
if
(
pending
)
{
var
server
=
servers
[
Math
.
floor
(
Math
.
random
()
*
servers
.
length
)];
let
server
=
servers
[
Math
.
floor
(
Math
.
random
()
*
servers
.
length
)];
var
result
=
JSON
.
stringify
({
"
address
"
:
server
.
address
,
let
room_id
=
crypto
.
randomBytes
(
9
).
toString
(
'
base64
'
).
slice
(
0
,
11
);
"
port
"
:
server
.
port
,
let
options_buffer
=
new
Buffer
(
6
);
"
password
"
:
crypto
.
randomBytes
(
12
).
toString
(
'
base64
'
)
options_buffer
.
writeUInt8
(
4
<<
4
,
1
);
});
let
checksum
=
0
;
for
(
let
i
=
1
;
i
<
options_buffer
.
length
;
i
++
)
{
for
(
var
client
of
[
res
,
pending
])
{
checksum
-=
options_buffer
.
readUInt8
(
i
)
}
options_buffer
.
writeUInt8
(
checksum
&
0xFF
,
0
);
for
(
let
client
of
[
res
,
pending
])
{
let
buffer
=
new
Buffer
(
6
);
let
secret
=
parseInt
(
client
.
password
)
%
65535
+
1
;
for
(
let
i
=
0
;
i
<
options_buffer
.
length
;
i
+=
2
)
{
buffer
.
writeUInt16LE
(
options_buffer
.
readUInt16LE
(
i
)
^
secret
,
i
)
}
let
password
=
buffer
.
toString
(
'
base64
'
)
+
room_id
;
let
result
=
JSON
.
stringify
({
"
address
"
:
server
.
address
,
"
port
"
:
server
.
port
,
"
password
"
:
password
});
client
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
application/json
'
,
'
Cache-Control
'
:
'
no-cache
'
});
client
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
application/json
'
,
'
Cache-Control
'
:
'
no-cache
'
});
client
.
end
(
result
)
client
.
end
(
result
)
}
}
pending
=
null
;
pending
=
null
;
console
.
log
(
'
matched
'
+
r
esult
);
console
.
log
(
'
matched
'
+
r
oom_id
);
}
else
{
}
else
{
pending
=
res
;
pending
=
res
;
res
.
on
(
'
close
'
,
()
=>
{
res
.
on
(
'
close
'
,
()
=>
{
console
.
log
(
'
connection closed.
'
)
console
.
log
(
'
connection closed.
'
)
;
if
(
pending
==
res
)
{
if
(
pending
==
res
)
{
pending
=
null
;
pending
=
null
;
}
}
})
})
}
}
}).
listen
(
3001
);
}).
listen
(
80
);
\ No newline at end of file
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