Skip to content

Commit

Permalink
core: patch plugin and server
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0Vu committed Dec 5, 2023
1 parent 9efe9f4 commit d8bd26b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
6 changes: 3 additions & 3 deletions katzenmint/s11n/descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const (

var (
// CertificateExpiration is the time a descriptor certificate will be valid for.
// 10 epoch by default
CertificateExpiration uint64 = 10
// 600 epoch by default
CertificateExpiration uint64 = 600
)

type nodeDescriptor struct {
Expand Down Expand Up @@ -93,7 +93,7 @@ func ParseDescriptor(b []byte, epochNow uint64) (*pki.MixDescriptor, error) {
if err != nil {
return nil, err
}
if epochNow > signedCert.Expiration {
if (epochNow + 1) > signedCert.Expiration {
return nil, cert.ErrCertificateExpired
}
payload, err := cert.GetCertified(b)
Expand Down
21 changes: 9 additions & 12 deletions plugin/cmd/meson-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,19 @@ func main() {
// Ensure that the log directory exists.
s, err := os.Stat(logDir)
if os.IsNotExist(err) {
fmt.Printf("Log directory '%s' doesn't exist.", logDir)
log.Errorf("Log directory '%s' doesn't exist.", logDir)
os.Exit(1)
}
if !s.IsDir() {
fmt.Println("Log directory must actually be a directory.")
log.Error("Log directory must actually be a directory.")
os.Exit(1)
}

// Log to a file.
logFile := path.Join(logDir, fmt.Sprintf("currency.%d.log", os.Getpid()))
f, err := os.Create(logFile)
if err != nil {
log.Errorf("Failed to create log file '%v: %v\n'", logFile, err)
log.Error("Exiting")
log.Errorf("Failed to create log file '%v: %v\n'Exiting\n", logFile, err)
os.Exit(-1)
}
logBackend := setupLoggerBackend(level, f)
Expand All @@ -161,16 +160,14 @@ func main() {
// Load config file.
cfg, err := config.LoadFile(*cfgFile)
if err != nil {
log.Errorf("Failed to load config file '%v: %v\n'", *cfgFile, err)
log.Error("Exiting")
log.Errorf("Failed to load config file '%v: %v\n'Exiting\n", *cfgFile, err)
os.Exit(-1)
}

// Start service.
currency, err := proxy.New(cfg)
if err != nil {
log.Errorf("Failed to load proxy config: %v\n", err)
log.Error("Exiting")
log.Errorf("Failed to load proxy config: %v\nExiting\n", err)
os.Exit(-1)
}
_requestHandler := func(response http.ResponseWriter, request *http.Request) {
Expand All @@ -181,18 +178,18 @@ func main() {
}
server := http.Server{}
socketFile := fmt.Sprintf("/tmp/%d.currency.socket", os.Getpid())
defer os.Remove(socketFile)
unixListener, err := net.Listen("unix", socketFile)
if err != nil {
log.Errorf("Failed to start server: %v\n", err)
log.Error("Exiting")
log.Errorf("Failed to start server: %v\nExiting\n", err)
os.Exit(-1)
}
http.HandleFunc("/request", _requestHandler)
http.HandleFunc("/parameters", _parametersHandler)
fmt.Printf("%s\n", socketFile)
err = server.Serve(unixListener)
if err != nil {
fmt.Println(err)
log.Errorf("Failed to start server: %v\nExiting\n", err)
os.Exit(-1)
}
os.Remove(socketFile)
}
2 changes: 1 addition & 1 deletion server/internal/packet/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (pkt *Packet) copyToRaw(b []byte) error {
func (pkt *Packet) disposeRaw() {
if len(pkt.Raw) == constants.PacketLength {
utils.ExplicitBzero(pkt.Raw)
rawPacketPool.Put(&pkt.Raw) // nolint: megacheck
rawPacketPool.Put(pkt.Raw) // nolint: megacheck
}
pkt.Raw = nil
}
Expand Down

0 comments on commit d8bd26b

Please sign in to comment.