Skip to content

Commit

Permalink
Add attribute 'secure port' for router languid protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorackerman committed Jul 29, 2016
1 parent e2a5d6f commit 8ff9006
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import javax.net.ssl.X509KeyManager;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.security.KeyStore;

// Wrap JSSEKeyManager with our own key manager so we can control handing out certificates
Expand Down Expand Up @@ -37,22 +35,4 @@ protected KeyStore getKeystore(final String type, final String provider, final S
System.setProperty("javax.net.ssl.keyStore", keyStorePath);
return KeyStoreHelper.getInstance().getKeyStore();
}

@Override
public ServerSocket createSocket (final int port) throws IOException
{
return new SniDecorator().addSni(super.createSocket(port));
}

@Override
public ServerSocket createSocket (final int port, final int backlog) throws IOException
{
return new SniDecorator().addSni(super.createSocket(port, backlog));
}

@Override
public ServerSocket createSocket (final int port, final int backlog, final InetAddress ifAddress) throws IOException
{
return new SniDecorator().addSni(super.createSocket(port, backlog, ifAddress));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class LanguidState {
private TrafficRouterManager trafficRouterManager;
private int port = 0;
private int apiPort = 0;
private int securePort = 0;

public void init() {
if (trafficRouterManager == null || trafficRouterManager.getTrafficRouter() == null) {
Expand All @@ -57,23 +58,32 @@ public void init() {
for (final String key : JSONObject.getNames(routers)) {
final JSONObject routerJson = routers.optJSONObject(key);

if (hostname.equalsIgnoreCase(key)) { // this is us
if (routerJson.has("port")) {
setPort(routerJson.optInt("port"));
}

if (routerJson.has("api.port")) {
setApiPort(routerJson.optInt("api.port"));
trafficRouterManager.setApiPort(apiPort);
}

break;
if (! hostname.equalsIgnoreCase(key)) {
continue;
}

initPorts(routerJson);
break;
}

setReady(true);
}

private void initPorts(final JSONObject routerJson) {
if (routerJson.has("port")) {
setPort(routerJson.optInt("port"));
}

if (routerJson.has("api.port")) {
setApiPort(routerJson.optInt("api.port"));
trafficRouterManager.setApiPort(apiPort);
}

if (routerJson.has("secure.port")) {
setSecurePort(routerJson.optInt("secure.port"));
}
}

public boolean isReady() {
return ready;
}
Expand Down Expand Up @@ -105,4 +115,12 @@ public TrafficRouterManager getTrafficRouterManager() {
public void setTrafficRouterManager(final TrafficRouterManager trafficRouterManager) {
this.trafficRouterManager = trafficRouterManager;
}

public int getSecurePort() {
return securePort;
}

public void setSecurePort(final int securePort) {
this.securePort = securePort;
}
}
2 changes: 1 addition & 1 deletion traffic_router/core/src/main/opt/tomcat/conf/server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<Connector port="443" protocol="com.comcast.cdn.traffic_control.traffic_router.protocol.LanguidProtocol" maxThreads="10000"
scheme="https" secure="true" SSLEnabled="true"
clientAuth="false" sslProtocol="TLS"
connectionTimeout="20000" mbeanPath="traffic-router:name=languidState" readyAttribute="Ready" portAttribute="Port"/>
connectionTimeout="20000" mbeanPath="traffic-router:name=languidState" readyAttribute="Ready" portAttribute="SecurePort"/>
<Connector port="3333" protocol="com.comcast.cdn.traffic_control.traffic_router.protocol.LanguidProtocol" maxThreads="10000"
connectionTimeout="20000" mbeanPath="traffic-router:name=languidState" readyAttribute="Ready" portAttribute="ApiPort"/>
<Engine name="traffic_router_core" defaultHost="localhost">
Expand Down

0 comments on commit 8ff9006

Please sign in to comment.