禁用Trustix 3.0.5的IPv6支持 ss5 socks server教程(二):配置
一月 09

ss5 socks server是一个相当完善的SOCKS v4 以及 v5 服务软件,支持Linux、Freebsd、Solaris。性能上相当不错,据官方网站介绍,在一台跑在Linux kernel 2.6.x的IBM x360的服务器,有跑到每秒2500个并发连接的纪录。ss5还提供了用户带宽控制功能,这可好像是目前唯一能找到的提供此功能的开源Socks服务了。

安装版本:3.6.4-3

系统安装环境:trustix 3.0.5

因为ss5有提供编译rpm的spec文件,所以就自己编了个给trustix 3.0.5的rpm来用,这样软件管理会方便些。

ss5的作者Matteo Ricchetti为了这个rpm包的东西能加入fedora,跟fedora的人认认真真地沟通了半年,真是佩服他这种一板一眼的认真劲。

下了最新版的ss5的软件包之后,发现要直接作成给trustix 3.0.5用的rpm还是不成的,一部分是因为trustix调整了部分initscripts的路径,另外一部分就是作者的疏忽了。做了相应的调整之后,才总算折腾出了一个给trustix 3.0.5用的比较完善的rpm包。我作的修改大致如下:

  • 根据trustix的initscripts路径作了调整
  • 修正了ss5的服务启动脚本中的一些错误
  • 修正了ss5的spec文件中的一些文件目录的权限设置
  • 增加了ss5的logrotate设置
  • 增加了ss5的服务启动参数设置文件:/etc/sysconfig/ss5

然后直接用rpmbuild编译一个rpm安装包出来就可以直接安装使用了。

  1. rpmbuild -bb --target=i686 /usr/src/trustix/specs/ss5.spec
  2. rpm -ivh /usr/src/trustix/rpms/i686/ss5-3.6.4-3.i686.rpm

可惜尝试着编译出来带epoll支持的ss5没法工作,我只好放弃了ss5对epoll的支持。

具体的修改如下,对于使用其他系统的兄弟,大致可以参考一下

对ss5-3.6.4-3.spec所做的修改

  1. --- /tmp/old/ss5-3.6.4-3.spec   2008-01-08 19:04:44.000000000 +0800
  2. +++ /tmp/new/ss5-3.6.4-3.spec   2008-01-10 11:36:34.753724380 +0800
  3. @@ -6,6 +6,7 @@
  4. Group: Applications/Internet
  5. URL: http://sourceforge.net/projects/ss5
  6. Source: http://prdownloads.sourceforge.net/ss5/ss5-3.6.4-3.tar.gz
  7. +Patch1: modify_for_trustix_3.0.5.patch
  8. BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
  9. BuildRequires: openldap-devel pam-devel
  10.  
  11. @@ -15,6 +16,7 @@
  12.  
  13. %prep
  14. %setup
  15. +%patch1 -p1
  16.  
  17. %build
  18.  
  19. @@ -43,7 +45,7 @@
  20. %files
  21. %defattr(755,root,root)
  22. %{_sbindir}/ss5
  23. -%{_initrddir}/ss5
  24. +%{_initdir}/ss5
  25. %{_libdir}/ss5/
  26.  
  27. %defattr(644,root,root)
  28. @@ -67,8 +69,11 @@
  29. %defattr(755,root,root)
  30. %{_localstatedir}/log/ss5
  31.  
  32. -%defattr(644,root,root)
  33. +%defattr(755,root,root)
  34. %dir %{_sysconfdir}/opt/ss5
  35. +%defattr(644,root,root)
  36. +%{_sysconfdir}/logrotate.d/ss5
  37. +%config(noreplace) %{_sysconfdir}/sysconfig/ss5
  38. %config(noreplace) %{_sysconfdir}/opt/ss5/ss5.conf
  39. %config(noreplace) %{_sysconfdir}/opt/ss5/ss5.passwd
  40. %config(noreplace) %{_sysconfdir}/pam.d/ss5

对ss5-3.6.4-3的软件包的修改

  1. --- ss5-3.6.4/Makefile.in    2007-05-24 23:59:53.000000000 +0800
  2. +++ ss5-3.6.4.new/Makefile.in    2008-01-10 11:06:59.052650112 +0800
  3. @@ -48,11 +48,15 @@
  4.      @( cp modules/mod_balance/SS5Logo.jpg $(dst_dir)$(lib_path_base)/ss5/ )
  5.  
  6.      @( if [ $(OS) = "Linux" ]; then \
  7. -    if [ ! -d $(dst_dir)/etc/rc.d/init.d ]; then mkdir -p $(dst_dir)/etc/rc.d/init.d; fi ; \
  8. +    if [ ! -d $(dst_dir)/etc/init.d ]; then mkdir -p $(dst_dir)/etc/init.d; fi ; \
  9. +    if [ ! -d $(dst_dir)/etc/logrotate.d ]; then mkdir -p $(dst_dir)/etc/logrotate.d; fi ; \
  10. +    if [ ! -d $(dst_dir)/etc/sysconfig ]; then mkdir -p $(dst_dir)/etc/sysconfig; fi ; \
  11.          fi )
  12.      @( if [ $(OS) = "Linux" ]; then \
  13. -    if [ ! -f $(dst_dir)/etc/rc.d/init.d/ss5 ]; then cp conf/ss5.init $(dst_dir)/etc/rc.d/init.d/ss5; \
  14. -    else cp conf/ss5.init $(dst_dir)/etc/rc.d/init.d/ss5.rpmnew ; fi ; \
  15. +    if [ ! -f $(dst_dir)/etc/init.d/ss5 ]; then cp conf/ss5.init $(dst_dir)/etc/init.d/ss5; \
  16. +    else cp conf/ss5.init $(dst_dir)/etc/init.d/ss5.rpmnew ; fi ; \
  17. +    if [ ! -f $(dst_dir)/etc/logrotate.d/ss5 ]; then cp conf/ss5.logrotate $(dst_dir)/etc/logrotate.d/ss5; fi ;\
  18. +    if [ ! -f $(dst_dir)/etc/sysconfig/ss5 ]; then cp conf/ss5.sysconfig $(dst_dir)/etc/sysconfig/ss5; fi ;\
  19.          fi )
  20.      @( if [ $(OS) = "SunOS" ]; then \
  21.      if [ ! -d $(dst_dir)/etc/init.d ]; then mkdir -p $(dst_dir)/etc/init.d; fi ; \
  22. @@ -134,7 +138,7 @@
  23.          fi )
  24.  
  25.      @( if [ $(OS) = "Linux" ]; then \
  26. -    if [ -f $(dst_dir)/etc/rc.d/init.d/ss5 ]; then rm -f $(dst_dir)/etc/rc.d/init.d/ss5; fi; \
  27. +    if [ -f $(dst_dir)/etc/init.d/ss5 ]; then rm -f $(dst_dir)/etc/init.d/ss5; fi; \
  28.          fi )
  29.      @( if [ $(OS) = "SunOS" ]; then \
  30.      if [ -f $(dst_dir)/etc/init.d/ss5 ]; then rm -f $(dst_dir)/etc/init.d/ss5; fi; \
  31. diff -Nur ss5-3.6.4/conf/ss5.init ss5-3.6.4.new/conf/ss5.init
  32. --- ss5-3.6.4/conf/ss5.init    2007-04-17 22:40:43.000000000 +0800
  33. +++ ss5-3.6.4.new/conf/ss5.init    2008-01-10 11:20:15.394071801 +0800
  34. @@ -4,12 +4,21 @@
  35. # description: This script takes care of starting \
  36. #              and stopping ss5
  37. #
  38. +# processname: ss5
  39. +# config: /etc/opt/ss5/ss5.conf
  40.  
  41. OS=`uname -s`
  42. if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
  43.  
  44. # Source function library.
  45. - . /etc/rc.d/init.d/functions
  46. +if [ -f /etc/init.d/functions ]; then
  47. +  . /etc/init.d/functions
  48. +elif [ /etc/rc.d/init.d/functions ]; then
  49. +  . /etc/rc.d/init.d/functions
  50. +else
  51. +  echo "Can't find functions file, exiting"
  52. +  exit 1
  53. +fi
  54.  
  55. # Source networking configuration.
  56.   . /etc/sysconfig/network
  57. @@ -20,6 +29,9 @@
  58.   [ -f /usr/sbin/ss5 ] || exit 0
  59. fi
  60.  
  61. +#set ulimit open file
  62. +ulimit -HSn 65535
  63. +
  64. # Test custom variables
  65. test -f /etc/sysconfig/ss5 && . /etc/sysconfig/ss5
  66.  
  67. @@ -31,7 +43,7 @@
  68.      if [ $OS = "Linux" ]; then
  69.              daemon /usr/sbin/ss5 -t $SS5_OPTS
  70.              touch /var/lock/subsys/ss5
  71. -    if [ $OS = "SunOS" ]; then
  72. +    elif [ $OS = "SunOS" ]; then
  73.              /usr/sbin/ss5 -t
  74.              touch /var/lock/subsys/ss5
  75.      else
  76. diff -Nur ss5-3.6.4/conf/ss5.logrotate ss5-3.6.4.new/conf/ss5.logrotate
  77. --- ss5-3.6.4/conf/ss5.logrotate    1970-01-01 08:00:00.000000000 +0800
  78. +++ ss5-3.6.4.new/conf/ss5.logrotate    2008-01-10 11:02:31.232586242 +0800
  79. @@ -0,0 +1,7 @@
  80. +/var/log/ss5/ss5.log {
  81. +    sharedscripts
  82. +    notifempty
  83. +    postrotate
  84. +        /usr/bin/killall -HUP ss5
  85. +    endscript
  86. +}
  87. diff -Nur ss5-3.6.4/conf/ss5.sysconfig ss5-3.6.4.new/conf/ss5.sysconfig
  88. --- ss5-3.6.4/conf/ss5.sysconfig    1970-01-01 08:00:00.000000000 +0800
  89. +++ ss5-3.6.4.new/conf/ss5.sysconfig    2008-01-10 11:05:33.542858180 +0800
  90. @@ -0,0 +1,4 @@
  91. +## These variables are used by ss5 socks service
  92. +## You will want to fill in your own ss5 start options
  93. +#
  94. +SS5_OPTS=""

3 Responses to “ss5 socks server教程(一):rpm安装包的制作”

  1. iakuf Says:

    ssh本身的socks代理就超级好用

  2. coolzsb Says:

    你的意思是利用ssh进行port forwarding吧?呵呵,那这就不是给用户用的,而是给自己用的东西了

    2008年一月 27 日 1:11 pm,iakuf大声嚷嚷道:

    ssh本身的socks代理就超级好用

  3. iakuf Says:

    到也是.你们的用户难道还有要用代理的需求???

Leave a Reply