ValidateRemoteAddr 判断ip端口是否合法
(ip string)
| 45 | |
| 46 | //ValidateRemoteAddr 判断ip端口是否合法 |
| 47 | func ValidateRemoteAddr(ip string) bool { |
| 48 | match, err := regexp.MatchString(`^(?:(?:1[0-9][0-9]\.)|(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:1[0-9][0-9])|(?:2[0-4][0-9])|(?:25[0-5])|(?:[1-9][0-9])|(?:[0-9]))\:(([0-9])|([1-9][0-9]{1,3})|([1-6][0-9]{0,4}))$`, ip) |
| 49 | if err != nil { |
| 50 | return false |
| 51 | } |
| 52 | return match |
| 53 | } |
| 54 | |
| 55 | //ValidateURL 判断ip端口是否合法 |
| 56 | func ValidateURL(url string) bool { |