Bind on all interfaces and allow connections from any host

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6307 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Charlie Groves
2010-11-25 01:35:06 +00:00
parent c0fb9e52c1
commit c4d108b1f7
@@ -41,7 +41,7 @@ import static com.threerings.NaryaLog.log;
/** /**
* Binds to a port and responds to "xmlsocket" requests on it with a policy file allowing access * Binds to a port and responds to "xmlsocket" requests on it with a policy file allowing access
* to all ports on a given hostname. * to all ports from any host.
*/ */
@Singleton @Singleton
public class PolicyServer extends ConnectionManager public class PolicyServer extends ConnectionManager
@@ -54,26 +54,22 @@ public class PolicyServer extends ConnectionManager
} }
/** /**
* Accepts xmlsocket requests on <code>socketPolicyPort</code> and responds that * Accepts xmlsocket requests on <code>socketPolicyPort</code> and responds any host may
* <code>publicServerHost</code> may connect to any port on this host. * connect to any port on this host.
*/ */
public void init (int socketPolicyPort, String publicServerHost) public void init (int socketPolicyPort)
{ {
_acceptor = _acceptor =
new ServerSocketChannelAcceptor(publicServerHost, new int[] { socketPolicyPort }, this); new ServerSocketChannelAcceptor(null, new int[] { socketPolicyPort }, this);
// build the XML once and for all // build the XML once and for all
StringBuilder policy = new StringBuilder("<?xml version=\"1.0\"?>\n"). StringBuilder policy = new StringBuilder("<cross-domain-policy>\n");
append("<cross-domain-policy>\n");
// if we're running on 843, serve a master policy file // if we're running on 843, serve a master policy file
if (socketPolicyPort == MASTER_PORT) { if (socketPolicyPort == MASTER_PORT) {
policy.append(" <site-control permitted-cross-domain-policies=\"master-only\"/>\n"); policy.append(" <site-control permitted-cross-domain-policies=\"master-only\"/>\n");
} }
for (String host : new String[] { publicServerHost }) { policy.append(" <allow-access-from domain=\"*\" to-ports=\"*\"/>\n");
policy.append(" <allow-access-from domain=\"").append(host).append("\"");
policy.append(" to-ports=\"*\"/>\n");
}
policy.append("</cross-domain-policy>\n"); policy.append("</cross-domain-policy>\n");
try { try {