Skip to content

Commit 02c660a

Browse files
committed
Add new media mirror
1 parent 3dff6cc commit 02c660a

8 files changed

Lines changed: 62 additions & 21 deletions

File tree

_config.i2p.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ theme_settings:
44
p2p_player:
55
media_urls_overwrite:
66
- http://codnaft43k7ncna2hfsxrzi2nqoxieu22vbyjkmhkwdrrta2ghlq.b32.i2p
7+
- http://codonfttnvztewul3qgathdxjr2fnv34udrqyc6quw3zptqojnea.b32.i2p
78
nostr:
89
spam_api_overwrite: http://codnaft43k7ncna2hfsxrzi2nqoxieu22vbyjkmhkwdrrta2ghlq.b32.i2p/nostr/spam.nostr.band/spam_api
910
profile_relays_overwrite:

_config.tor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ theme_settings:
44
p2p_player:
55
media_urls_overwrite:
66
- http://codonaftct3jsouvfyrjq4yumyngzv3el2msndf5oddccktgghnw7eyd.onion
7+
- http://codonafte3ygy3szn5qwsdje4vp6mwobvzd75jl4ytyrb262cpkaegid.onion
78
nostr:
89
spam_api_overwrite: http://codonaftct3jsouvfyrjq4yumyngzv3el2msndf5oddccktgghnw7eyd.onion/nostr/spam.nostr.band/spam_api
910
profile_relays_overwrite:

_do.cr

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,23 +1085,25 @@ end
10851085

10861086
def check_i2p_host(host : String)
10871087
puts("checking i2p configuration at #{host}")
1088-
private_key = File.read_lines(HOSTS_DIR.join(host).join("etc/i2pd/tunnels.conf"))
1089-
.select { |i| i.starts_with?("keys =") }
1090-
.map { |i| i.split(" = ")[1] }[0]
10911088
service_dir = Path["/var/lib/i2pd"]
1089+
private_keys = File.read_lines(HOSTS_DIR.join(host).join("etc/i2pd/tunnels.conf"))
1090+
.select { |i| i.starts_with?("keys =") }
1091+
.map { |i| i.split(" = ")[1] }
10921092
check_manual_upload(host, owner: "i2pd", group: "i2pd", mode: 700, path: service_dir)
1093-
check_manual_upload(host, owner: "i2pd", group: "i2pd", mode: 440, path: service_dir.join(private_key))
1093+
private_keys.each { |i| check_manual_upload(host, owner: "i2pd", group: "i2pd", mode: 440, path: service_dir.join(i)) }
10941094
end
10951095

10961096
def check_tor_host(host : String)
10971097
puts("checking tor configuration at #{host}")
1098-
service_dir = Path[File.read_lines(HOSTS_DIR.join(host).join("etc/tor/torrc"))
1098+
service_dirs = File.read_lines(HOSTS_DIR.join(host).join("etc/tor/torrc"))
10991099
.select { |i| i.starts_with?("HiddenServiceDir") }
1100-
.map { |i| i.split(" ")[1] }[0]]
1101-
check_manual_upload(host, owner: "tor", group: "tor", mode: 700, path: service_dir)
1102-
check_manual_upload(host, owner: "tor", group: "tor", mode: 400, path: service_dir.join("hs_ed25519_secret_key"))
1103-
check_manual_upload(host, owner: "tor", group: "tor", mode: 400, path: service_dir.join("hs_ed25519_public_key"))
1104-
check_manual_upload(host, owner: "tor", group: "tor", mode: 400, path: service_dir.join("hostname"), data: service_dir.basename)
1100+
.map { |i| Path[i.split(" ")[1]] }
1101+
service_dirs.map { |i|
1102+
check_manual_upload(host, owner: "tor", group: "tor", mode: 700, path: i)
1103+
check_manual_upload(host, owner: "tor", group: "tor", mode: 400, path: i.join("hs_ed25519_secret_key"))
1104+
check_manual_upload(host, owner: "tor", group: "tor", mode: 400, path: i.join("hs_ed25519_public_key"))
1105+
check_manual_upload(host, owner: "tor", group: "tor", mode: 400, path: i.join("hostname"), data: i.basename)
1106+
}
11051107
end
11061108

11071109
def check_ssh_hosts(ps : Array(Tuple(Int64, String)))

_hosts/media.codonaft/etc/i2pd/tunnels.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[anon-website]
1+
[codonaft-media]
22
type = http
33
host = 127.0.0.1
44
port = 80

_hosts/media.codonaft/etc/nginx/http.d/media.conf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ server {
6464
}
6565

6666
location ~ \.(m3u8|mp4|ts|vtt|webp)$ {
67-
if ($http_origin != $origin) {
68-
return 404;
69-
}
70-
7167
add_header "Access-Control-Allow-Origin" $origin always;
7268

7369
add_header Cache-Control "public, max-age=31536000, immutable";
@@ -136,10 +132,6 @@ server {
136132
ignore_invalid_headers on;
137133

138134
location ~ \.(m3u8|mp4|ts|vtt|webp)$ {
139-
if ($http_origin != $origin) {
140-
return 404;
141-
}
142-
143135
add_header "Access-Control-Allow-Origin" $origin always;
144136

145137
add_header Cache-Control "public, max-age=31536000, immutable";

_hosts/mirror.codonaft/etc/i2pd/tunnels.conf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[anon-website]
1+
[codonaft]
22
type = http
33
host = 127.0.0.1
44
port = 80
@@ -8,3 +8,9 @@ keys = codonftbnpdkjwyflssto3iklawhuthbe37l6swigegqkyyfmiqa.b32.i2p.dat
88
#inbound.quantity = 3
99
#outbound.length = 2
1010
#outbound.quantity = 3
11+
12+
[codonaft-media-mirror]
13+
type = http
14+
host = 127.0.0.1
15+
port = 80
16+
keys = codonfttnvztewul3qgathdxjr2fnv34udrqyc6quw3zptqojnea.b32.i2p.dat

_hosts/mirror.codonaft/etc/nginx/http.d/mirror.conf

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ server {
2525

2626
server {
2727
set $i2p_host "codonaft.i2p";
28-
2928
listen 127.0.0.1:80;
3029
server_name codonftbnpdkjwyflssto3iklawhuthbe37l6swigegqkyyfmiqa.b32.i2p;
3130
root /var/www/$i2p_host;
@@ -57,3 +56,40 @@ server {
5756
index index.html;
5857
error_page 404 =200 /404.html;
5958
}
59+
60+
server {
61+
listen 127.0.0.1:80;
62+
server_name codonafte3ygy3szn5qwsdje4vp6mwobvzd75jl4ytyrb262cpkaegid.onion;
63+
root /var/www/media.codonaft.com;
64+
65+
location ~ \.(m3u8|mp4|ts|vtt|webp)$ {
66+
set $origin http://codonaftbvv4j5k7nsrdivbdblycqrng5ls2qkng6lm77svepqjyxgid.onion;
67+
68+
add_header "Access-Control-Allow-Origin" $origin always;
69+
70+
add_header Cache-Control "public, max-age=31536000, immutable";
71+
expires 1y;
72+
73+
limit_rate_after 5M;
74+
limit_rate 5M;
75+
}
76+
}
77+
78+
server {
79+
set $i2p_host "codonaft.i2p";
80+
listen 127.0.0.1:80;
81+
server_name codonfttnvztewul3qgathdxjr2fnv34udrqyc6quw3zptqojnea.b32.i2p;
82+
root /var/www/media.codonaft.com;
83+
84+
location ~ \.(m3u8|mp4|ts|vtt|webp)$ {
85+
set $origin http://$i2p_host;
86+
87+
add_header "Access-Control-Allow-Origin" $origin always;
88+
89+
add_header Cache-Control "public, max-age=31536000, immutable";
90+
expires 1y;
91+
92+
limit_rate_after 5M;
93+
limit_rate 5M;
94+
}
95+
}

_hosts/mirror.codonaft/etc/tor/torrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ ExcludeExitNodes {am}, {az}, {by}, {ee}, {ge}, {kg}, {kz}, {lt}, {ly}, {md}, {ru
44

55
HiddenServiceDir /var/lib/tor/codonaftbvv4j5k7nsrdivbdblycqrng5ls2qkng6lm77svepqjyxgid.onion/
66
HiddenServicePort 80 127.0.0.1:80
7+
8+
HiddenServiceDir /var/lib/tor/codonafte3ygy3szn5qwsdje4vp6mwobvzd75jl4ytyrb262cpkaegid.onion/
9+
HiddenServicePort 80 127.0.0.1:80

0 commit comments

Comments
 (0)