OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #!/bin/sh /etc/rc.common |
3 | office | 2 | # Copyright (C) 2010-2014 OpenWrt.org |
1 | office | 3 | |
4 | START=99 |
||
5 | USE_PROCD=1 |
||
6 | PROG=/usr/sbin/omcproxy |
||
7 | |||
3 | office | 8 | # Uncomment to enable verbosity |
9 | #OPTIONS="-v" |
||
1 | office | 10 | PROXIES="" |
11 | |||
3 | office | 12 | |
1 | office | 13 | omcproxy_add_proxy() { |
3 | office | 14 | local uplink downlink scope proxy |
1 | office | 15 | config_get uplink $1 uplink |
3 | office | 16 | config_get downlink $1 downlink |
17 | config_get scope $1 scope |
||
1 | office | 18 | |
3 | office | 19 | proxy="" |
1 | office | 20 | |
3 | office | 21 | network_get_device updev $uplink |
22 | [ -n "$updev" ] || return 0 |
||
1 | office | 23 | |
3 | office | 24 | for network in $downlink; do |
25 | network_get_device downdev $network |
||
26 | [ -n "$downdev" ] && proxy="$proxy,$downdev" |
||
1 | office | 27 | |
3 | office | 28 | # Disable in-kernel querier while ours is active |
29 | [ -f /sys/class/net/$downdev/bridge/multicast_querier ] && \ |
||
30 | echo 0 > /sys/class/net/$downdev/bridge/multicast_querier |
||
1 | office | 31 | done |
32 | |||
33 | [ -n "$proxy" ] || return 0 |
||
34 | [ -n "$scope" ] && proxy="$proxy,scope=$scope" |
||
35 | |||
3 | office | 36 | PROXIES="$PROXIES $updev$proxy" |
37 | |||
1 | office | 38 | } |
39 | |||
3 | office | 40 | omcproxy_add_trigger() { |
41 | local uplink downlink |
||
1 | office | 42 | config_get uplink $1 uplink |
3 | office | 43 | config_get downlink $1 downlink |
1 | office | 44 | |
3 | office | 45 | for network in $uplink $downlink; do |
46 | procd_add_interface_trigger "interface.*" $network /etc/init.d/omcproxy restart |
||
1 | office | 47 | done |
48 | } |
||
49 | |||
3 | office | 50 | omcproxy_add_firewall() { |
1 | office | 51 | config_get uplink $1 uplink |
3 | office | 52 | config_get downlink $1 downlink |
1 | office | 53 | |
54 | upzone=$(fw3 -q network $uplink 2>/dev/null) |
||
55 | [ -n "$upzone" ] || return 0 |
||
56 | |||
57 | json_add_object "" |
||
58 | json_add_string type rule |
||
59 | json_add_string src "$upzone" |
||
60 | json_add_string proto igmp |
||
61 | json_add_string target ACCEPT |
||
62 | json_close_object |
||
63 | |||
64 | json_add_object "" |
||
65 | json_add_string type rule |
||
66 | json_add_string family ipv6 |
||
67 | json_add_string src "$upzone" |
||
68 | json_add_string proto icmp |
||
69 | json_add_string src_ip fe80::/10 |
||
70 | json_add_array icmp_type |
||
71 | json_add_string "" 130/0 |
||
72 | json_add_string "" 131/0 |
||
73 | json_add_string "" 132/0 |
||
74 | json_add_string "" 143/0 |
||
75 | json_close_array |
||
76 | json_add_string target ACCEPT |
||
77 | json_close_object |
||
78 | |||
3 | office | 79 | for network in $downlink; do |
80 | downzone=$(fw3 -q network $network 2>/dev/null) |
||
1 | office | 81 | [ -n "$downzone" ] || continue |
82 | |||
83 | json_add_object "" |
||
84 | json_add_string type rule |
||
85 | json_add_string src "$upzone" |
||
86 | json_add_string dest "$downzone" |
||
87 | json_add_string family ipv4 |
||
3 | office | 88 | json_add_string proto any |
1 | office | 89 | json_add_string dest_ip "224.0.0.0/4" |
90 | json_add_string target ACCEPT |
||
91 | json_close_object |
||
92 | |||
93 | json_add_object "" |
||
94 | json_add_string type rule |
||
95 | json_add_string src "$upzone" |
||
96 | json_add_string dest "$downzone" |
||
97 | json_add_string family ipv6 |
||
3 | office | 98 | json_add_string proto any |
1 | office | 99 | json_add_string dest_ip "ff00::/8" |
100 | json_add_string target ACCEPT |
||
101 | json_close_object |
||
102 | done |
||
103 | } |
||
104 | |||
105 | service_triggers() { |
||
106 | procd_add_reload_trigger "omcproxy" |
||
107 | } |
||
108 | |||
109 | start_service() { |
||
3 | office | 110 | include /lib/functions |
1 | office | 111 | |
112 | config_load omcproxy |
||
3 | office | 113 | config_foreach omcproxy_add_proxy proxy |
1 | office | 114 | |
115 | [ -n "$PROXIES" ] || return 0 |
||
116 | |||
117 | procd_open_instance |
||
118 | procd_set_param command $PROG |
||
119 | [ -n "$OPTIONS" ] && procd_append_param command $OPTIONS |
||
120 | procd_append_param command $PROXIES |
||
121 | procd_set_param respawn |
||
122 | |||
3 | office | 123 | procd_open_trigger |
124 | config_foreach omcproxy_add_trigger proxy |
||
125 | procd_close_trigger |
||
126 | |||
1 | office | 127 | procd_open_data |
128 | |||
129 | json_add_array firewall |
||
3 | office | 130 | config_foreach omcproxy_add_firewall proxy |
1 | office | 131 | json_close_array |
132 | |||
133 | procd_close_data |
||
134 | |||
135 | procd_close_instance |
||
136 | |||
3 | office | 137 | # Increase maximum IPv4 group memberships per socket |
1 | office | 138 | echo 128 > /proc/sys/net/ipv4/igmp_max_memberships |
139 | } |
||
140 | |||
141 | service_started() { |
||
142 | procd_set_config_changed firewall |
||
143 | } |