connect to websocket through a list of ports

This commit is contained in:
Thibault Duplessis 2014-03-03 21:59:25 +01:00
parent c092ecd147
commit c757d9b204
5 changed files with 21 additions and 13 deletions

View file

@ -51,7 +51,6 @@ object Environment
def netDomain = apiEnv.Net.Domain
def netBaseUrl = apiEnv.Net.BaseUrl
def netPort = apiEnv.Net.Port
def isProd = apiEnv.isProd

View file

@ -32,7 +32,6 @@ zen: Boolean = false)(body: Html)(implicit ctx: Context)
</head>
<body class="@ctx.currentTheme.cssClass @ctx.currentBg"
data-troll="@ctx.troll.toString"
data-port="@netPort"
data-accept-languages="@acceptLanguages.mkString(",")">
<div id="site_description">@trans.freeOnlineChessGamePlayChessNowInACleanInterfaceNoRegistrationNoAdsNoPluginRequiredPlayChessWithComputerFriendsOrRandomOpponents()</div>
<div id="top" class="clearfix">

15
doc/iptables Normal file
View file

@ -0,0 +1,15 @@
-- local
iptables -t nat -A OUTPUT -p tcp --dport 6661 -j DNAT --to 192.168.1.59:9663
iptables -t nat -A OUTPUT -p tcp --dport 6662 -j DNAT --to 192.168.1.59:9663
iptables -t nat -A OUTPUT -p tcp --dport 6663 -j DNAT --to 192.168.1.59:9663
iptables -t nat -A OUTPUT -p tcp --dport 6664 -j DNAT --to 192.168.1.59:9663
iptables -t nat -A OUTPUT -p tcp --dport 6665 -j DNAT --to 192.168.1.59:9663
iptables -t nat -A OUTPUT -p tcp --dport 6666 -j DNAT --to 192.168.1.59:9663
-- prod
iptables -t nat -A PREROUTING -p tcp --dport 6661 -j DNAT --to 91.121.106.120:9004
iptables -t nat -A PREROUTING -p tcp --dport 6662 -j DNAT --to 91.121.106.120:9004
iptables -t nat -A PREROUTING -p tcp --dport 6663 -j DNAT --to 91.121.106.120:9004
iptables -t nat -A PREROUTING -p tcp --dport 6664 -j DNAT --to 91.121.106.120:9004
iptables -t nat -A PREROUTING -p tcp --dport 6665 -j DNAT --to 91.121.106.120:9004
iptables -t nat -A PREROUTING -p tcp --dport 6666 -j DNAT --to 91.121.106.120:9004

View file

@ -18,7 +18,6 @@ final class Env(
private[api] val apiToken = config getString "api.token"
object Net {
val Port = config getInt "http.port"
val Domain = config getString "net.domain"
val Protocol = config getString "net.protocol"
val BaseUrl = config getString "net.base_url"

View file

@ -82,10 +82,8 @@ var storage = {
if (self.options.resetUrl || self.options.prodPipe) {
storage.remove(self.options.baseUrlKey);
}
if (window.opera) {
self.options.baseUrls = self.options.baseUrls.reverse();
} else if (self.options.prodPipe) {
self.options.baseUrls = ['socket.en.lichess.org'];
if (self.options.prodPipe) {
self.options.baseUrls = ['en.lichess.org:6661'];
}
self.connect();
$(window).on('unload', function() {
@ -95,7 +93,6 @@ var storage = {
strongSocket.available = window.WebSocket || window.MozWebSocket;
strongSocket.prototype = {
connect: function() {
if (this.ws && this.ws.readyState === 0) return; // firefox delay
var self = this;
self.destroy();
self.autoReconnect = true;
@ -451,11 +448,10 @@ var storage = {
},
params: {},
options: {
baseUrls: [
'socket.' + document.domain,
document.domain + ':' + $('body').data('port')
],
baseUrlKey: 'surl',
baseUrls: _.map([1,2,3,4,5,6], function(i) {
return document.domain + ':' + (6660 + i);
}),
baseUrlKey: 'surl2',
name: "site",
lagTag: $('#connection_lag'),
debug: location.search.indexOf('debug-ws') != -1,