squid重定向(python 代码)
2024-09-30 13:44:17
#!/usr/bin/python2.7
# coding: utf-8
import sys,os,stat
import transport
def redirect_url(line,concurrent):
list = line.split(' ')
if concurrent:
old_url = list[0]
else:
old_url = list[1]
# f = open('/etc/squid3/abc.txt','w')
# f.write('old_url:'+old_url)
# f.close()
new_url = '\n'
if old_url.endswith('.avi/'):
new_url = 'http://www.baidu.com/' + new_url
# f = open('/etc/squid3/abc.txt','w')
# f.write('old_url:'+old_url)
# f.close()
elif old_url.endswith('.exe/'):
new_url = 'http://www.google.com/' + new_url
return new_url
def main(concurrent=True):
line = sys.stdin.readline().strip()
while line:
# f = open('/etc/squid3/abc.txt','w')
# f.write('line:'+line)
# f.close()
new_url = redirect_url(line,concurrent)
id=''
if concurrent:
id+=line.split(' ')[0]+' '
new_url = id + new_url
# f = open('/etc/squid3/abc.txt','w')
# f.write('new_url:'+ new_url)
# f.close()
sys.stdout.write(new_url)
sys.stdout.flush()
line = sys.stdin.readline().strip()
if __name__=='__main__':
main(len(sys.argv)>1 and sys.argv[1]=='-c')
最新文章
- 11.14 T2 小x的旅行(小x的旅行)
- CmdBuild
- Dubbox监控在服务器中的安装
- 200多个js技巧代码
- 软件工程 speedsnail 冲刺7
- linux下valgrind的使用概述
- 04_SSM框架整合(Spring+SpringMVC+MyBatis)
- 也谈android开发图像压缩
- android studio 无法在可视化页面预览布局文件
- 关于js事件冒泡和时间捕获
- codecomb 2093【牛宫】
- Android 启动过程的底层实现
- iOS 内存泄漏
- 利刃 MVVMLight 8:DispatchHelper在多线程和调度中的使用
- FiddlerCoreAPI开发(二)截获HTTPS流量
- Redis -->; Redis架构设计
- JS 存储
- [转] babel-plugin-react-css-modules配置
- gridview导excel及解决导出中文乱码的方法
- 持续集成之二:搭建SVN服务器(整合Apache+Subversion)