|
1 | | -# IP Guardian - IP 安全、限流與自動封鎖 |
| 1 | +# (未完成) IP Guardian - IP 安全、限流與自動封鎖 |
| 2 | +> IP Guardian 是一個高效能的 Go 語言 IP 安全防護系統,提供即時威脅偵測、動態風險評分、設備指紋識別等多層安全防護機制。系統採用 Redis 作為高速快取層,支援併發處理與自動化威脅回應。 |
2 | 3 |
|
3 | | -## 概述 |
| 4 | +[](https://github.com/pardnchiu/golang-ip-guardian/releases) |
4 | 5 |
|
5 | | -IP Guardian 是一個高效能的 Go 語言 IP 安全防護系統,提供即時威脅偵測、動態風險評分、設備指紋識別等多層安全防護機制。系統採用 Redis 作為高速快取層,支援併發處理與自動化威脅回應。 |
| 6 | +## 待處理項目 |
| 7 | +- AbuseIPDB 驗證 |
| 8 | +- Geo 驗證 |
6 | 9 |
|
7 | 10 | ## 主要特色 |
8 | 11 |
|
@@ -421,56 +424,32 @@ graph TD |
421 | 424 |
|
422 | 425 | ### 配置介紹 |
423 | 426 |
|
| 427 | +#### 可用參數 |
424 | 428 | ```go |
425 | | -config := &golangIPGuardian.Config{ |
426 | | - Redis: golangIPGuardian.Redis{ |
427 | | - Host: "redis-cluster.example.com", |
428 | | - Port: 6379, |
429 | | - Password: "your-redis-password", |
430 | | - DB: 1, |
431 | | - }, |
432 | | - Email: &golangIPGuardian.EmailConfig{ |
433 | | - Host: "smtp.gmail.com", |
434 | | - Port: 587, |
435 | | - Username: "your-email@example.com", |
436 | | - Password: "your-app-password", |
437 | | - From: "security@your-domain.com", |
438 | | - To: []string{"admin@your-domain.com"}, |
439 | | - }, |
440 | | - Log: golangIPGuardian.LogConfig{ |
441 | | - Path: "/var/log/ipguardian", |
442 | | - Stdout: false, |
443 | | - MaxSize: 100 * 1024 * 1024, // 100MB |
444 | | - }, |
445 | | - Parameter: golangIPGuardian.Parameter{ |
446 | | - // 阻擋策略 |
447 | | - BlockToBan: 5, // 5次阻擋後永久封鎖 |
448 | | - BlockTimeMin: 1800, // 30分鐘起始阻擋 |
449 | | - BlockTimeMax: 86400 * 7, // 7天最大阻擋 |
450 | | - |
451 | | - // 流量限制 |
452 | | - RateLimitNormal: 200, // 正常用戶 200 req/min |
453 | | - RateLimitSuspicious: 50, // 可疑用戶 50 req/min |
454 | | - RateLimitDangerous: 10, // 危險用戶 10 req/min |
455 | | - |
456 | | - // 關聯限制 |
457 | | - SessionMultiIP: 3, // 單一 Session 最多 3 個 IP |
458 | | - IPMultiDevice: 5, // 單一 IP 最多 5 個設備 |
459 | | - DeviceMultiIP: 2, // 單一設備最多 2 個 IP |
460 | | - |
461 | | - // 風險評分 |
462 | | - ScoreNormal: 0, |
463 | | - ScoreSuspicious: 40, // 降低可疑閾值 |
464 | | - ScoreDangerous: 70, // 降低危險閾值 |
465 | | - ScoreSessionMultiIP: 20, |
466 | | - ScoreIPMultiDevice: 25, |
467 | | - ScoreDeviceMultiIP: 15, |
468 | | - ScoreFpMultiSession: 30, |
469 | | - ScoreGeoHopping: 20, |
470 | | - ScoreGeoFrequentSwitch: 25, |
471 | | - ScoreGeoRapidChange: 30, |
472 | | - ScoreLongConnection: 10, |
473 | | - ScoreIntervalRequest: 15, |
474 | | - }, |
| 429 | +type Parameter struct { |
| 430 | + BlockToBan int `json:"block_to_ban"` // 封鎖到禁止的次數 |
| 431 | + BlockTimeMin int `json:"block_time_min"` // 最小封鎖時間(秒) |
| 432 | + BlockTimeMax int `json:"block_time_max"` // 最大限制時間(秒) |
| 433 | + RateLimitNormal int `json:"rate_limit_normal"` // 正常請求速率限制 |
| 434 | + RateLimitSuspicious int `json:"rate_limit_suspicious"` // 可疑請求速率限制 |
| 435 | + RateLimitDangerous int `json:"rate_limit_dangerous"` // 危險請求速率限制 |
| 436 | + SessionMultiIP int `json:"session_multi_ip"` // 單一 Session 允許的最大 IP 數 |
| 437 | + IPMultiDevice int `json:"ip_multi_device"` // 單一 IP 允許的最大設備數 |
| 438 | + DeviceMultiIP int `json:"device_multi_ip"` // 單一設備允許的最大 IP 數 |
| 439 | + LoginFailure int `json:"login_failure"` // 單一 Session 允許的最大登入失敗次數 |
| 440 | + NotFound404 int `json:"not_found_404"` // 單一 Session 允許的最大 404 請求數 |
| 441 | + ScoreNormal int `json:"score_normal"` // 正常請求的風險分數 |
| 442 | + ScoreSuspicious int `json:"score_suspicious"` // 可疑請求的風險分數 |
| 443 | + ScoreDangerous int `json:"score_dangerous"` // 危險請求的風險分數 |
| 444 | + ScoreSessionMultiIP int `json:"score_session_multi_ip"` // 單一 Session 允許的最大 IP 數可疑分數 |
| 445 | + ScoreIPMultiDevice int `json:"score_ip_multi_device"` // 單一 IP 允許的最大設備數可疑分數 |
| 446 | + ScoreDeviceMultiIP int `json:"score_device_multi_ip"` // 單一設備允許的最大 IP 數可疑分數 |
| 447 | + ScoreFpMultiSession int `json:"score_fp_multi_session"` // 單一指紋允許的最大 Session 數可疑分數 |
| 448 | + ScoreGeoHopping int `json:"score_geo_hopping"` // 地理位置跳躍可疑分數 |
| 449 | + ScoreGeoFrequentSwitch int `json:"score_geo_frequent_switch"` // 地理位置頻繁切換可疑分數 |
| 450 | + ScoreGeoRapidChange int `json:"score_geo_rapid_change"` // 地理位置快速變化可疑分數 |
| 451 | + ScoreIntervalRequest int `json:"score_interval_request"` // 短時間內的請求數可疑分數 |
| 452 | + ScoreFrequencyRequest int `json:"score_frequency_request"` // 請求頻率可疑分數 |
| 453 | + ScoreLongConnection int `json:"score_long_connection"` // 長連接可疑分數 |
475 | 454 | } |
476 | 455 | ``` |
0 commit comments