Advertisement
Xtraeme

map different local port to different external port

Nov 12th, 2014
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.32 KB | None | 0 0
  1. diff --git a/src/org/chris/portmapper/PortMapperCli.java b/src/org/chris/portmapper/PortMapperCli.java
  2. index 641ab0b..cea8acd 100644
  3. --- a/src/org/chris/portmapper/PortMapperCli.java
  4. +++ b/src/org/chris/portmapper/PortMapperCli.java
  5. @@ -301,10 +301,24 @@
  6.             final String[] optionValues) throws RouterException {
  7.  
  8.         final String remoteHost = null;
  9. -       final String internalClient = optionValues[0];
  10. -       final int internalPort = Integer.parseInt(optionValues[1]);
  11. -       final int externalPort = Integer.parseInt(optionValues[2]);
  12. -       final Protocol protocol = Protocol.valueOf(optionValues[3]);
  13. +       String internalClient = null;
  14. +       int indexstart = 0;
  15. +              
  16. +       if (optionValues.length == 4)
  17. +       {
  18. +               internalClient = optionValues[0];
  19. +       } else if (optionValues.length == 3){
  20. +               internalClient = router.getLocalHostAddress();
  21. +               indexstart = 1;
  22. +       } else {
  23. +               logger.error("Invalid number of arguments for option "
  24. +                       + ADD_OPTION);
  25. +               return;
  26. +       }
  27. +                
  28. +       final int internalPort = Integer.parseInt(optionValues[1 - indexstart]);
  29. +       final int externalPort = Integer.parseInt(optionValues[2 - indexstart]);
  30. +       final Protocol protocol = Protocol.valueOf(optionValues[3 - indexstart]);
  31.  
  32.         final String description = "PortMapper " + protocol + "/"
  33.                 + internalClient + ":" + internalPort;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement