/*## (c) SECURITY EXPLORATIONS    2018 poland                                #*/
/*##     http://www.security-explorations.com                                #*/

/* THIS SOFTWARE IS PROTECTED BY DOMESTIC AND INTERNATIONAL COPYRIGHT LAWS    */
/* UNAUTHORISED COPYING OF THIS SOFTWARE IN EITHER SOURCE OR BINARY FORM IS   */
/* EXPRESSLY FORBIDDEN. ANY USE, INCLUDING THE REPRODUCTION, MODIFICATION,    */
/* DISTRIBUTION, TRANSMISSION, RE-PUBLICATION, STORAGE OR DISPLAY OF ANY      */
/* PART OF THE SOFTWARE, FOR COMMERCIAL OR ANY OTHER PURPOSES REQUIRES A      */
/* VALID LICENSE FROM THE COPYRIGHT HOLDER.                                   */

/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS    */
/* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,*/
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    */
/* SECURITY EXPLORATIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF  */
/* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE     */
/* SOFTWARE.                                                                  */

import java.lang.*;
import java.io.*;
import java.net.*;

public class Servers {
 public static final String LOCALHOST = "127.0.0.1";

 public static String host_addr;

 public static void main(String[] args) {
  try {
   System.out.println("Simple DNS/HTTP Servers");

   if (args.length==1) {
    host_addr=args[0];
   } else {
    host_addr=InetAddress.getLocalHost().getHostAddress();
   }

   if (host_addr.equals(LOCALHOST)) {
    System.out.println("error: bad host addr "+host_addr);
    System.exit(1);
   }

   System.out.println("Servers listening on: "+host_addr);

   DNSServer.start(host_addr);
   SSDPServer.start(host_addr);
   HTTPServer.start(host_addr,80);
   HTTPServer.start(host_addr,8080);
   RunJava.start(host_addr);
  } catch (Exception e) {
   e.printStackTrace();
  }
 }
}

