mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-22 09:58:14 -05:00
fee53a8384
support ip limit for hy
46 lines
1019 B
Go
46 lines
1019 B
Go
package node
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/Yuzuki616/V2bX/common/file"
|
|
"github.com/Yuzuki616/V2bX/node/lego"
|
|
"log"
|
|
)
|
|
|
|
func (c *Controller) renewCertTask() {
|
|
l, err := lego.New(c.CertConfig)
|
|
if err != nil {
|
|
log.Print("new lego error: ", err)
|
|
return
|
|
}
|
|
err = l.RenewCert()
|
|
if err != nil {
|
|
log.Print("renew cert error: ", err)
|
|
return
|
|
}
|
|
}
|
|
|
|
func (c *Controller) requestCert() error {
|
|
if c.CertConfig.CertFile == "" || c.CertConfig.KeyFile == "" {
|
|
return fmt.Errorf("cert file path or key file path not exist")
|
|
}
|
|
switch c.CertConfig.CertMode {
|
|
case "reality", "none", "":
|
|
return nil
|
|
case "dns", "http":
|
|
if file.IsExist(c.CertConfig.CertFile) && file.IsExist(c.CertConfig.KeyFile) {
|
|
return nil
|
|
}
|
|
l, err := lego.New(c.CertConfig)
|
|
if err != nil {
|
|
return fmt.Errorf("create lego object error: %s", err)
|
|
}
|
|
err = l.CreateCert()
|
|
if err != nil {
|
|
return fmt.Errorf("create cert error: %s", err)
|
|
}
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unsupported certmode: %s", c.CertConfig.CertMode)
|
|
}
|