import os, sys, urllib, urlparse
from conary.conarycfg import ConaryConfiguration


def main(args):
    cfg = ConaryConfiguration(False)
    cfg.read('/etc/conaryrc', exception=False)
    for schema, uri in cfg.proxy.items():
        hostpart = urlparse.urlsplit(uri)[1]
        host, port = urllib.splitport(hostpart)
        if not port:
            if schema == 'https':
                port = '443'
            else:
                port = '80'
        os.system('/sbin/iptables -A FORWARD-SLAVE -m state --state NEW '
                '-m tcp -p tcp --dport %s -d %s -j ACCEPT 2>/dev/null'
                % (port, host))


if __name__ == '__main__':
    sys.exit(main(sys.argv[1:]))

import os, sys, urllib, urlparse
from conary.conarycfg import ConaryConfiguration


def main(args):
    cfg = ConaryConfiguration(False)
    cfg.read('/etc/conaryrc', exception=False)
    import epdb;epdb.st()
    for schema, uri in cfg.proxy.items():
        userhostport = urlparse.urlsplit(uri)[1]
        hostport = urllib.splituser(userhostport)[1]
        host, port = urllib.splitport(hostport)
        if not port:
            if schema == 'https':
                port = '443'
            else:
                port = '80'
        os.system('/sbin/iptables -A FORWARD-SLAVE -m state --state NEW '
                '-m tcp -p tcp --dport %s -d %s -j ACCEPT 2>/dev/null'
                % (port, host))


if __name__ == '__main__':
    sys.exit(main(sys.argv[1:]))

Fix proxy URIs with credentials in them
Fix proxy URIs with credentials in them

  import os, sys, urllib, urlparse
  from conary.conarycfg import ConaryConfiguration
  
  
  def main(args):
      cfg = ConaryConfiguration(False)
      cfg.read('/etc/conaryrc', exception=False)
+     import epdb;epdb.st()
      for schema, uri in cfg.proxy.items():
-         hostpart = urlparse.urlsplit(uri)[1]
+         userhostport = urlparse.urlsplit(uri)[1]
+         hostport = urllib.splituser(userhostport)[1]
-         host, port = urllib.splitport(hostpart)
+         host, port = urllib.splitport(hostport)
          if not port:
              if schema == 'https':
                  port = '443'
              else:
                  port = '80'
          os.system('/sbin/iptables -A FORWARD-SLAVE -m state --state NEW '
                  '-m tcp -p tcp --dport %s -d %s -j ACCEPT 2>/dev/null'
                  % (port, host))
  
  
  if __name__ == '__main__':
      sys.exit(main(sys.argv[1:]))
  
Fix proxy URIs with credentials in them
## Code Before:
import os, sys, urllib, urlparse
from conary.conarycfg import ConaryConfiguration


def main(args):
    cfg = ConaryConfiguration(False)
    cfg.read('/etc/conaryrc', exception=False)
    for schema, uri in cfg.proxy.items():
        hostpart = urlparse.urlsplit(uri)[1]
        host, port = urllib.splitport(hostpart)
        if not port:
            if schema == 'https':
                port = '443'
            else:
                port = '80'
        os.system('/sbin/iptables -A FORWARD-SLAVE -m state --state NEW '
                '-m tcp -p tcp --dport %s -d %s -j ACCEPT 2>/dev/null'
                % (port, host))


if __name__ == '__main__':
    sys.exit(main(sys.argv[1:]))

## Instruction:
Fix proxy URIs with credentials in them
## Code After:
import os, sys, urllib, urlparse
from conary.conarycfg import ConaryConfiguration


def main(args):
    cfg = ConaryConfiguration(False)
    cfg.read('/etc/conaryrc', exception=False)
    import epdb;epdb.st()
    for schema, uri in cfg.proxy.items():
        userhostport = urlparse.urlsplit(uri)[1]
        hostport = urllib.splituser(userhostport)[1]
        host, port = urllib.splitport(hostport)
        if not port:
            if schema == 'https':
                port = '443'
            else:
                port = '80'
        os.system('/sbin/iptables -A FORWARD-SLAVE -m state --state NEW '
                '-m tcp -p tcp --dport %s -d %s -j ACCEPT 2>/dev/null'
                % (port, host))


if __name__ == '__main__':
    sys.exit(main(sys.argv[1:]))
