… | |
… | |
10 | CONF BIND_ADDRESSES = [[undef, 13327]]; |
10 | CONF BIND_ADDRESSES = [[undef, 13327]]; |
11 | |
11 | |
12 | our $MAX_DETECT = 16; # how many bytes to raed to identify the protocol |
12 | our $MAX_DETECT = 16; # how many bytes to raed to identify the protocol |
13 | |
13 | |
14 | our @LISTENERS; |
14 | our @LISTENERS; |
|
|
15 | |
|
|
16 | sub flash_policy_server { |
|
|
17 | my ($fh) = @_; |
|
|
18 | |
|
|
19 | # socket policy file, just write answer and hope the kernel accepts it in one go |
|
|
20 | syswrite $fh, <<EOF . "\x00" |
|
|
21 | <?xml version="1.0"?> |
|
|
22 | <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> |
|
|
23 | <cross-domain-policy> |
|
|
24 | <allow-access-from domain="*" to-ports="*"/> |
|
|
25 | </cross-domain-policy> |
|
|
26 | EOF |
|
|
27 | } |
15 | |
28 | |
16 | for (@$BIND_ADDRESSES) { |
29 | for (@$BIND_ADDRESSES) { |
17 | my ($host, $port) = @$_; |
30 | my ($host, $port) = @$_; |
18 | cf::info "listening on ", (format_hostport $host, $port), "\n"; |
31 | cf::info "listening on ", (format_hostport $host, $port), "\n"; |
19 | |
32 | |
… | |
… | |
41 | $ns->inbuf_append ($buf); |
54 | $ns->inbuf_append ($buf); |
42 | |
55 | |
43 | } elsif ($buf =~ /^GET / && defined &ext::http::server) { # http or websocket |
56 | } elsif ($buf =~ /^GET / && defined &ext::http::server) { # http or websocket |
44 | undef $w; |
57 | undef $w; |
45 | |
58 | |
46 | &ext::http::server ($fh, $buf); |
59 | &ext::http::server ($id, $fh, $buf); |
|
|
60 | |
|
|
61 | } elsif ($buf =~ /^<policy-file-request\/>\x00/) { |
|
|
62 | undef $w; |
|
|
63 | |
|
|
64 | flash_policy_server $fh; |
47 | |
65 | |
48 | } elsif (length $buf >= $MAX_DETECT) { # unable to detect protocol |
66 | } elsif (length $buf >= $MAX_DETECT) { # unable to detect protocol |
49 | undef $w; |
67 | undef $w; |
50 | |
68 | |
51 | cf::info "$id: protocol detection error\n"; |
69 | cf::info "$id: protocol detection error\n"; |