Skip to content

Commit

Permalink
Transfer code from MKLE to UPNPIGD
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMahdjoub committed Feb 7, 2022
1 parent 9df095e commit d929af8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,39 +212,6 @@ static boolean isNotValidRemoteAddress(String host, NetworkAddressFactory networ



static class RequestHttpHandler implements HttpHandler {

private final com.distrimind.upnp_igd.transport.Router router;
private final NetworkAddressFactory networkAddressFactory;

RequestHttpHandler(com.distrimind.upnp_igd.transport.Router router, NetworkAddressFactory networkAddressFactory) {
this.router = router;
this.networkAddressFactory=networkAddressFactory;
}

// This is executed in the request receiving thread!
public void handle(final HttpExchange httpExchange) throws IOException {
InetSocketAddress isa=httpExchange.getRemoteAddress();
if (isa==null)
return;
InetAddress receivedOnLocalAddress =
networkAddressFactory.getLocalAddress(
null,
isa.getAddress() instanceof Inet6Address,
isa.getAddress()
);
if (receivedOnLocalAddress==null)
return;
router.received(
new HttpExchangeUpnpStream(router.getProtocolFactory(), httpExchange) {
@Override
protected Connection createConnection() {
return new HttpServerConnection(httpExchange);
}
}
);
}
}
private static class HttpServerConnection implements Connection {

protected HttpExchange exchange;
Expand Down Expand Up @@ -2143,27 +2110,6 @@ public ServiceDescriptorBinder createServiceDescriptorBinderUDA10() {
}


@Override
public StreamServer<?> createStreamServer(NetworkAddressFactory networkAddressFactory) {
return new StreamServerImpl(
new StreamServerConfigurationImpl(
networkAddressFactory.getStreamListenPort()
)
) {
@Override
synchronized public void init(InetAddress bindAddress, com.distrimind.upnp_igd.transport.Router router) throws InitializationException {
try {
InetSocketAddress socketAddress = new InetSocketAddress(bindAddress, configuration.getListenPort());

server = HttpServer.create(socketAddress, configuration.getTcpConnectionBacklog());
server.createContext("/", new UpnpIGDAgent.RequestHttpHandler(router, networkAddressFactory));

} catch (Exception ex) {
throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex, ex);
}
}
};
}
}

class AndroidUpnpServiceConfiguration extends com.distrimind.upnp_igd.android.AndroidUpnpServiceConfiguration {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5864
5865

0 comments on commit d929af8

Please sign in to comment.