Fix DHT bootstrap by adding configurable public URL
Some checks are pending
CI Pipeline / Run Tests (push) Waiting to run
CI Pipeline / Lint Code (push) Waiting to run
CI Pipeline / Security Scan (push) Waiting to run
CI Pipeline / E2E Tests (push) Blocked by required conditions

This commit is contained in:
Enki 2025-08-27 17:47:08 -07:00
parent 9c22093aca
commit bbc7c259b4
7 changed files with 64 additions and 1 deletions

View File

@ -7,6 +7,7 @@ gateway:
enabled: true enabled: true
port: 9877 port: 9877
max_upload_size: 10GB max_upload_size: 10GB
public_url: "https://gateway.sovbit.host" # Public URL for BitTorrent/DHT bootstrap
# Embedded Blossom server # Embedded Blossom server
blossom_server: blossom_server:

View File

@ -366,7 +366,14 @@ func NewGateway(cfg *config.Config, storage *storage.Backend) *Gateway {
} }
// Set public URL for tracker functionality // Set public URL for tracker functionality
publicURL := fmt.Sprintf("http://localhost:%d", cfg.Gateway.Port) publicURL := cfg.Gateway.PublicURL
if publicURL == "" {
// Fallback to localhost if not configured (for development)
publicURL = fmt.Sprintf("http://localhost:%d", cfg.Gateway.Port)
log.Printf("Warning: No public_url configured, using localhost fallback: %s", publicURL)
} else {
log.Printf("Using configured public URL: %s", publicURL)
}
// Initialize transcoding manager // Initialize transcoding manager
var transcodingManager TranscodingManager var transcodingManager TranscodingManager

View File

@ -32,6 +32,7 @@ type GatewayConfig struct {
Enabled bool `yaml:"enabled"` Enabled bool `yaml:"enabled"`
Port int `yaml:"port"` Port int `yaml:"port"`
MaxUploadSize string `yaml:"max_upload_size"` MaxUploadSize string `yaml:"max_upload_size"`
PublicURL string `yaml:"public_url"`
} }
// BlossomServerConfig configures the embedded Blossom server // BlossomServerConfig configures the embedded Blossom server

View File

@ -195,6 +195,7 @@ func (tm *Manager) markTranscodingQueued(fileHash string) {
// markTranscodingCompleted records that transcoding completed successfully // markTranscodingCompleted records that transcoding completed successfully
func (tm *Manager) markTranscodingCompleted(fileHash string) { func (tm *Manager) markTranscodingCompleted(fileHash string) {
tm.updateTranscodingStatus(fileHash, "completed") tm.updateTranscodingStatus(fileHash, "completed")
log.Printf("DEBUG: Marked transcoding completed for file %s", fileHash)
} }
// markTranscodingFailed records that transcoding failed // markTranscodingFailed records that transcoding failed

View File

@ -405,6 +405,18 @@ class GatewayUI {
const response = await fetch('/api/files'); const response = await fetch('/api/files');
if (response.ok) { if (response.ok) {
const data = await response.json(); const data = await response.json();
// Debug logging
console.log('API /api/files response:', {
fileCount: data.files ? data.files.length : 0,
files: data.files ? data.files.map(f => ({
name: f.name,
hash: f.file_hash?.substring(0, 8),
is_video: f.is_video,
storage_type: f.storage_type
})) : []
});
if (data.files && data.files.length > 0) { if (data.files && data.files.length > 0) {
// Merge server files with local uploads, avoiding duplicates // Merge server files with local uploads, avoiding duplicates
const allFiles = [...data.files]; const allFiles = [...data.files];

View File

@ -545,6 +545,39 @@ fi
# Enable and start nginx # Enable and start nginx
systemctl start nginx systemctl start nginx
# Configure firewall (UFW)
echo "🔥 Configuring firewall (UFW)..."
if command -v ufw >/dev/null 2>&1; then
# Enable UFW if not already enabled (non-interactive)
ufw --force enable
# Allow essential ports
echo " Opening HTTP/HTTPS ports..."
ufw allow 80/tcp comment "HTTP (nginx)"
ufw allow 443/tcp comment "HTTPS (nginx)"
echo " Opening SSH access..."
ufw allow 22/tcp comment "SSH"
echo " Opening BitTorrent/DHT ports..."
ufw allow 9877/tcp comment "Gateway API"
ufw allow 6883/udp comment "DHT node (peer discovery)"
# Optional: Standard BitTorrent ports for better peer connectivity
ufw allow 6881:6889/tcp comment "BitTorrent TCP"
ufw allow 6881:6889/udp comment "BitTorrent UDP"
# Reload firewall rules
ufw --force reload
echo "✅ Firewall configured successfully"
echo " Active rules:"
ufw status numbered | head -20
else
echo "⚠️ UFW not found - firewall not configured"
echo " Please manually open ports: 80, 443, 22, 9877/tcp, 6883/udp"
fi
echo "" echo ""
echo "🎉 Torrent Gateway systemd setup completed!" echo "🎉 Torrent Gateway systemd setup completed!"
echo "" echo ""
@ -559,6 +592,14 @@ echo "3. Check status:"
echo " systemctl status torrent-gateway" echo " systemctl status torrent-gateway"
echo " journalctl -u torrent-gateway -f" echo " journalctl -u torrent-gateway -f"
echo "" echo ""
echo "🔥 Firewall ports opened:"
echo " 80/tcp - HTTP (nginx)"
echo " 443/tcp - HTTPS (nginx)"
echo " 22/tcp - SSH"
echo " 9877/tcp - Gateway API"
echo " 6883/udp - DHT node (CRITICAL for peer discovery)"
echo " 6881-6889/tcp,udp - BitTorrent protocol"
echo ""
echo "4. Run health checks:" echo "4. Run health checks:"
echo " $INSTALL_DIR/scripts/health_check.sh" echo " $INSTALL_DIR/scripts/health_check.sh"
echo "" echo ""

BIN
torrent-gateway Executable file

Binary file not shown.