Skip to content

Commit

Permalink
v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Aug 3, 2024
1 parent 4590309 commit 627d742
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
TAG="v0.0.1-$(date +'%Y%m%d%H%M%S')"
TAG="v0.0.2-$(date +'%Y%m%d%H%M%S')"
git tag $TAG
git push origin $TAG
env:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

- [x] 本机邮件常用端口检测
- [x] 常用邮件平台的SMTP、POP3、IMAP协议检测
- [x] 部分Windows10系统下打勾打叉编码错误显示,已判断是Win时使用Y/N显示而不是勾叉

## TODO

- [ ] 部分Windows10系统下打勾打叉编码错误显示,需要判断是Win时使用Y/N显示而不是勾叉
- [ ] 常用端口多地区是否阻断检测

## 使用(Usage)
Expand Down
47 changes: 42 additions & 5 deletions email/emailcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/tls"
"fmt"
"net"
"runtime"
"strings"
"sync"
"time"
Expand All @@ -20,27 +21,48 @@ type Result struct {
func isLocalPortOpen(port string) string {
ln, err := net.Listen("tcp", ":"+port)
if err != nil {
if runtime.GOOS == "windows" {
return "N"
}
return "✘"
}
ln.Close()
if runtime.GOOS == "windows" {
return "Y"
}
return "✔"
}

func checkConnection(host string, port string) string {
address := net.JoinHostPort(host, port)
conn, err := net.DialTimeout("tcp", address, 5*time.Second)
if err != nil {
if runtime.GOOS == "windows" {
return "N"
}
return "✘"
}
defer conn.Close()
reader := bufio.NewReader(conn)
response, err := reader.ReadString('\n')
if err != nil {
if runtime.GOOS == "windows" {
return "N"
}
return "✘"
}
status := "✘"
var status string
if runtime.GOOS == "windows" {
status = "N"
} else {
status = "✘"
}
if strings.Split(response, " ")[0] == "220" || strings.Split(response, " ")[0] == "+OK" || strings.Contains(response, "* OK") {
status = "✔"
if runtime.GOOS == "windows" {
status = "Y"
} else {
status = "✔"
}
}
return status
}
Expand All @@ -49,17 +71,32 @@ func checkConnectionSSL(host string, port string) string {
address := net.JoinHostPort(host, port)
conn, err := tls.DialWithDialer(&net.Dialer{Timeout: 5 * time.Second}, "tcp", address, &tls.Config{})
if err != nil {
if runtime.GOOS == "windows" {
return "N"
}
return "✘"
}
defer conn.Close()
reader := bufio.NewReader(conn)
response, err := reader.ReadString('\n')
if err != nil {
if runtime.GOOS == "windows" {
return "N"
}
return "✘"
}
status := "✘"
var status string
if runtime.GOOS == "windows" {
status = "N"
} else {
status = "✘"
}
if strings.HasPrefix(response, "220") {
status = "✔"
if runtime.GOOS == "windows" {
status = "Y"
} else {
status = "✔"
}
}
return status
}
Expand Down Expand Up @@ -200,4 +237,4 @@ func EmailCheck() string {
smtpChanMap[name], smtpsChanMap[name], pop3ChanMap[name], pop3sChanMap[name], imapChanMap[name], imapsChanMap[name]))
}
return strings.Join(results, "\n")
}
}
2 changes: 1 addition & 1 deletion model/model.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package model

var Version = "v0.0.1"
var Version = "v0.0.2"
var LocalServers = []string{"25", "465", "110", "995", "143", "993"}
var Platforms = []string{"QQ", "163", "Sohu", "Yandex", "Gmail", "Outlook", "Office365", "Yahoo", "MailCOM", "MailRU", "AOL", "GMX", "Sina"}
var SmtpServers = map[string]string{
Expand Down

0 comments on commit 627d742

Please sign in to comment.