Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jean-Paul Smets
slapos
Commits
4ec2a7ea
Commit
4ec2a7ea
authored
Jan 03, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update kvm-proxy js script to work with node.js 0.6
Huuge perf improvements, does no longer drop connexions.
parent
9c9f05d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
slapos/recipe/kvm_frontend/template/kvm-proxy.js
slapos/recipe/kvm_frontend/template/kvm-proxy.js
+10
-6
No files found.
slapos/recipe/kvm_frontend/template/kvm-proxy.js
View file @
4ec2a7ea
...
...
@@ -13,22 +13,26 @@ var listenInterface = process.argv[2],
redirect
=
process
.
argv
[
7
]
||
false
,
isRawIPv6
;
if
(
process
.
argv
.
length
<
7
)
{
console
.
error
(
"
Too few arguments. Exiting.
"
);
process
.
exit
(
1
);
}
isRawIPv6
=
function
checkipv6
(
str
)
{
// Inspired by http://forums.intermapper.com/viewtopic.php?t=452
return
(
/^
\s
*
((([
0-9A-Fa-f
]{1,4}
:
){7}([
0-9A-Fa-f
]{1,4}
|:
))
|
(([
0-9A-Fa-f
]{1,4}
:
){6}(
:
[
0-9A-Fa-f
]{1,4}
|
((
25
[
0-5
]
|2
[
0-4
]\d
|1
\d\d
|
[
1-9
]?\d)(\.(
25
[
0-5
]
|2
[
0-4
]\d
|1
\d\d
|
[
1-9
]?\d)){3})
|:
))
|
(([
0-9A-Fa-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
|1
\d\d
|
[
1-9
]?\d)(\.(
25
[
0-5
]
|2
[
0-4
]\d
|1
\d\d
|
[
1-9
]?\d)){3}))
|:
)))(
%.+
)?\s
*$/
.
test
(
str
));
}(
listenInterface
);
// Dummy middleware that throws 404 not found.
/**
* Dummy middleware that throws 404 not found. Does not contain websocket
* middleware.
*/
var
middlewareNotFound
=
function
(
req
,
res
,
proxy
)
{
res
.
statusCode
=
404
;
res
.
setHeader
(
'
Content-Type
'
,
'
text/plain
'
);
res
.
end
(
'
This URL is not known. Please check your URL or contact your
'
+
'
SlapOS administrator.
'
);
};
middlewareNotFound
.
proxyWebSocketRequest
=
function
(
req
,
socket
,
head
,
next
)
{
console
.
log
(
'
stop
'
);
socket
.
end
();
};
/**
* Rewrite URL to match Zope's virtual host monster if we use vifib
...
...
@@ -74,7 +78,7 @@ var proxyServer = httpProxy.createServer(
}}
);
//
We gonna rock this civilization
.
//
Release the beast
.
proxyServer
.
listen
(
port
,
listenInterface
);
console
.
log
(
'
HTTPS server started and listening at
'
+
listenInterface
+
'
:
'
+
port
);
...
...
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