(Feat): Initial Commit
Some checks failed
Build & Test / build-test (push) Has been cancelled
Build & Test / swagger-codegen-cli (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled

This commit is contained in:
2026-07-03 19:41:31 +05:30
commit 7e940c83a7
461 changed files with 45002 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
package transport
import (
"errors"
"fmt"
"net/smtp"
)
type loginAuth struct {
username []byte
password []byte
host string
}
func LoginAuth(username string, password string, host ...string) smtp.Auth {
auth := &loginAuth{
username: []byte(username),
password: []byte(password),
host: "",
}
if len(host) > 0 {
auth.host = host[0]
}
return auth
}
func (a *loginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
if len(a.host) > 0 && server.Name != a.host {
return "", nil, errors.New("wrong host name")
}
return "LOGIN", a.username, nil
}
func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) {
if more {
switch string(fromServer) {
case "Username:":
return a.username, nil
case "Password:":
return a.password, nil
default:
return nil, fmt.Errorf("unknown challenge received from server: %q", fromServer)
}
}
return nil, nil
}