Bugzilla – Attachment 2410 Details for
Bug 1169
Enhancement request to support subnet configurations for Host configuration directive
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
python script to test local ip
file_1169.txt (text/plain), 999 bytes, created by
Marc Zonzon
on 2014-02-20 03:03:17 AEDT
(
hide
)
Description:
python script to test local ip
Filename:
MIME Type:
Creator:
Marc Zonzon
Created:
2014-02-20 03:03:17 AEDT
Size:
999 bytes
patch
obsolete
>import socket >import re >import sys >private_re = r'^192\.168\.\d\d?\d?\.\d\d?\d?$' >private_re += '|' + r'10\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?$' >private_re += '|' + r'172\.(?:1[0-6]|2\d|3[0-1])\.\d\d?\d?.\d\d?\d?$' > >#!/usr/bin/env python3 >import socket >import re >import sys >private_re = r'^192\.168\.\d\d?\d?\.\d\d?\d?$' >private_re += '|' + r'10\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?$' >private_re += '|' + r'172\.(?:1[0-6]|2\d|3[0-1])\.\d\d?\d?.\d\d?\d?$' > >def check_local(local_re, hostname): > local = re.compile(local_re) > hostip = socket.gethostbyname(hostname) > return local.match(hostip) > >def main(): > import argparse > parser = argparse.ArgumentParser(description='Match local ips.') > parser.add_argument('hostname', help='hostname or ip') > parser.add_argument('--local', dest='local_re', default=private_re) > args = parser.parse_args() > raise SystemExit(0 if check_local(args.local_re, args.hostname) else 1) > >if __name__ == '__main__': > main()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1169
:
2409
| 2410 |
2411