diff --git a/p2pproxy/src/org/linphone/p2pproxy/core/media/rtprelay/RtpRelayService.java b/p2pproxy/src/org/linphone/p2pproxy/core/media/rtprelay/RtpRelayService.java index 592fe2e9b..3429b2af4 100644 --- a/p2pproxy/src/org/linphone/p2pproxy/core/media/rtprelay/RtpRelayService.java +++ b/p2pproxy/src/org/linphone/p2pproxy/core/media/rtprelay/RtpRelayService.java @@ -26,9 +26,7 @@ import java.io.ObjectOutputStream; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; -import java.net.SocketAddress; import java.net.SocketException; -import java.net.URI; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; diff --git a/p2pproxy/src/org/linphone/p2pproxy/core/stun/AddressInfo.java b/p2pproxy/src/org/linphone/p2pproxy/core/stun/AddressInfo.java new file mode 100644 index 000000000..08975d2c2 --- /dev/null +++ b/p2pproxy/src/org/linphone/p2pproxy/core/stun/AddressInfo.java @@ -0,0 +1,26 @@ +/* +p2pproxy Copyright (C) 2007 Jehan Monnier () + +AddressInfo.java - . + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +package org.linphone.p2pproxy.core.stun; + +import java.net.InetSocketAddress; + +public class AddressInfo { + InetSocketAddress mPublicAddress,mPrivateAddress; +} diff --git a/p2pproxy/src/org/linphone/p2pproxy/core/stun/StunClient.java b/p2pproxy/src/org/linphone/p2pproxy/core/stun/StunClient.java new file mode 100644 index 000000000..6bfbdb7e3 --- /dev/null +++ b/p2pproxy/src/org/linphone/p2pproxy/core/stun/StunClient.java @@ -0,0 +1,60 @@ +/* +p2pproxy Copyright (C) 2007 Jehan Monnier () + +StunClient.java - . + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +package org.linphone.p2pproxy.core.stun; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import org.linphone.p2pproxy.api.P2pProxyException; +import org.linphone.p2pproxy.core.JxtaNetworkManager; +import org.linphone.p2pproxy.core.P2pProxyAdvertisementNotFoundException; +import org.linphone.p2pproxy.core.sipproxy.NetworkResourceAdvertisement; + +public class StunClient { + private List mStunServerList; + JxtaNetworkManager mJxtaNetworkManager; + + StunClient(List aStunServerList) { + mStunServerList = aStunServerList; + } + StunClient(JxtaNetworkManager aJxtaNetworkManager) throws P2pProxyException { + //need to acquire stun server address() + mJxtaNetworkManager = aJxtaNetworkManager; + try { + mStunServerList = acquireStunServerAddress(); + } catch (Exception e) { + throw new P2pProxyException(e); + } + } + private List acquireStunServerAddress() throws P2pProxyAdvertisementNotFoundException, InterruptedException, IOException { + List lStunServerAdv = (List) mJxtaNetworkManager.getAdvertisementList(null, StunServer.ADV_NAME, true); + List lSocketAddressList = new ArrayList(lStunServerAdv.size()); + for (NetworkResourceAdvertisement lNetworkResourceAdvertisement: lStunServerAdv) { + URI lServerUri = URI.create(lNetworkResourceAdvertisement.getAddress()); + lSocketAddressList.add(new InetSocketAddress(lServerUri.getHost(),lServerUri.getPort())); + } + return lSocketAddressList; + } + + +} diff --git a/p2pproxy/src/org/linphone/p2pproxy/core/stun/StunServer.java b/p2pproxy/src/org/linphone/p2pproxy/core/stun/StunServer.java index 7bb5204db..1ac6fe88a 100644 --- a/p2pproxy/src/org/linphone/p2pproxy/core/stun/StunServer.java +++ b/p2pproxy/src/org/linphone/p2pproxy/core/stun/StunServer.java @@ -50,6 +50,7 @@ import de.javawi.jstun.util.Address; public class StunServer implements GenericUdpSession.MessageHandler { private static Logger mLog = Logger.getLogger(StunServer.class); private final DatagramSocket mSocket; + public final static String ADV_NAME = "p2p-proxy-stunserver"; public StunServer(DatagramSocket mListeningSocket) throws SocketException { mSocket = mListeningSocket; }