2007年03月07日

塩とDishuberを使えば良い。
用意するもの
config.yaml
cidr.tt
contents.tt
frame.tt
以上のファイルと最新のDishuberだけである。

それぞれのファイルの中身はとても単純。

frame.tt

[% content %]

contents.tt
[% FOREACH cidr = meta.cidr %]
[% cidr -%]
[% END %]

cidr.tt
# [% meta.source.meta.carrier %]
[% FOREACH cidr = source %]
Allow from [% cidr -%]
[% END %]

そして config.yaml

plugins:
- module: Source::MobileCIDR
cid: docomo
config:
carrier: DoCoMo

- module: Source::MobileCIDR
cid: ezweb
config:
carrier: EZweb

- module: Source::MobileCIDR
cid: thirdforce
config:
carrier: Vodafone

- module: Source::MobileCIDR
cid: willcom
config:
carrier: AirHPhone

- module: Filter::SourceChain
cid: cidr
config:
sources:
- docomo
- ezweb
- thirdforce
- willcom

- module: Template::File
cid: cidr
config:
path: ./samples/mobilecider/cidr.tt

- module: Format::TT
cid: cidr
config:
template: cidr
source: cidr


- module: Template::File
cid: frame
config:
path: ./samples/mobilecider/frame.tt

- module: Template::File
cid: contents
config:
path: ./samples/mobilecider/contents.tt

- module: Format::TT
cid: contents
config:
template: contents


- module: Build::TT
cid: conf
config:
frame: frame
contents: contents
contents_sources:
- name: cidr
source: format::cidr


- module: Publish::Local
config:
source: build::conf
path: mobilecidr_httpd.conf

たったこれだけで、apacheの設定が自動的に書けてしまうのである。

cidr.ttの中身を書き換えればiptablesで出来たりYAMLでデータ吐けたりXMLでデータ吐けたりと自由自在です。
特定のキャリアだけ設定する事も簡単です。

出力例は以下の通り

# I

Allow from 210.153.84.0/24
Allow from 210.136.161.0/24
Allow from 210.153.86.0/24
Allow from 210.153.87.0/24
Allow from 203.138.180.0/24
Allow from 203.138.181.0/24
Allow from 203.138.203.0/24

# E

Allow from 210.169.40.0/24
Allow from 210.196.3.192/26
Allow from 210.196.5.192/26
Allow from 210.230.128.0/24
Allow from 210.230.141.192/26
Allow from 210.234.105.32/29
Allow from 210.234.108.64/26
Allow from 210.251.1.192/26
Allow from 210.251.2.0/27
Allow from 211.5.1.0/24
Allow from 211.5.2.128/25
Allow from 211.5.7.0/24
Allow from 218.222.1.0/24
Allow from 61.117.0.0/24
Allow from 61.117.1.0/24
Allow from 61.117.2.0/26
Allow from 61.202.3.0/24
Allow from 219.108.158.0/26
Allow from 219.125.148.0/24
Allow from 222.5.63.0/24
Allow from 222.7.56.0/24
Allow from 222.5.62.128/25
Allow from 222.7.57.0/24
Allow from 59.135.38.128/25
Allow from 219.108.157.0/25
Allow from 219.125.151.128/25

# V

Allow from 202.179.204.0/24
Allow from 202.253.96.248/29
Allow from 210.146.7.192/26
Allow from 210.146.60.192/26
Allow from 210.151.9.128/26
Allow from 210.169.130.112/29
Allow from 210.169.130.120/29
Allow from 210.169.176.0/24
Allow from 210.175.1.128/25
Allow from 210.228.189.0/24
Allow from 211.8.159.128/25

# H

Allow from 61.198.142.0/24
Allow from 219.108.14.0/24
Allow from 61.198.161.0/24
Allow from 219.108.0.0/24
Allow from 61.198.249.0/24
Allow from 219.108.1.0/24
Allow from 61.198.250.0/24
Allow from 219.108.2.0/24
Allow from 61.198.253.0/24
Allow from 219.108.3.0/24
Allow from 61.198.254.0/24
Allow from 219.108.4.0/24
Allow from 61.198.255.0/24
Allow from 219.108.5.0/24
Allow from 61.204.3.0/25
Allow from 219.108.6.0/24
Allow from 61.204.4.0/24
Allow from 221.119.0.0/24
Allow from 61.204.6.0/25
Allow from 221.119.1.0/24
Allow from 125.28.4.0/24
Allow from 221.119.2.0/24
Allow from 125.28.5.0/24
Allow from 221.119.3.0/24
Allow from 125.28.6.0/24
Allow from 221.119.4.0/24
Allow from 125.28.7.0/24
Allow from 221.119.5.0/24
Allow from 125.28.8.0/24
Allow from 221.119.6.0/24
Allow from 211.18.235.0/24
Allow from 221.119.7.0/24
Allow from 211.18.238.0/24
Allow from 221.119.8.0/24
Allow from 211.18.239.0/24
Allow from 221.119.9.0/24
Allow from 125.28.11.0/24
Allow from 125.28.13.0/24
Allow from 125.28.12.0/24
Allow from 125.28.14.0/24
Allow from 125.28.2.0/24
Allow from 125.28.3.0/24
Allow from 211.18.232.0/24
Allow from 211.18.233.0/24
Allow from 211.18.236.0/24
Allow from 211.18.237.0/24
Allow from 125.28.0.0/24
Allow from 125.28.1.0/24
Allow from 61.204.0.0/24
Allow from 210.168.246.0/24
Allow from 210.168.247.0/24
Allow from 219.108.7.0/24
Allow from 61.204.2.0/24
Allow from 61.204.5.0/24
Allow from 61.198.129.0/24
Allow from 61.198.140.0/24
Allow from 61.198.141.0/24
Allow from 125.28.15.0/24
Allow from 61.198.165.0/24
Allow from 61.198.166.0/24
Allow from 61.198.168.0/24
Allow from 61.198.169.0/24
Allow from 61.198.170.0/24
Allow from 61.198.248.0/24
Allow from 125.28.16.0/24
Allow from 125.28.17.0/24
Allow from 211.18.234.0/24
Allow from 219.108.8.0/24
Allow from 219.108.9.0/24
Allow from 219.108.10.0/24
Allow from 61.198.163.0/24
Allow from 219.108.15.0/24
Allow from 61.198.130.0/24

Posted by Yappo at 2007年03月07日 19:18 | TrackBack | Perl
Comments
Post a comment









Remember personal info?






コメントを投稿する前に↓の場所にnospamと入力してください。