fix stuff up
This commit is contained in:
parent
0cd12cf944
commit
ea91db2f58
8
contrib/backends/nntpchand/.dir-locals.el
Normal file
8
contrib/backends/nntpchand/.dir-locals.el
Normal file
@ -0,0 +1,8 @@
|
||||
;; thanks stack overflow
|
||||
;; https://stackoverflow.com/questions/4012321/how-can-i-access-the-path-to-the-current-directory-in-an-emacs-directory-variabl
|
||||
((nil . ((eval . (set (make-local-variable 'my-project-path)
|
||||
(file-name-directory
|
||||
(let ((d (dir-locals-find-file ".")))
|
||||
(if (stringp d) d (car d))))))
|
||||
(eval . (setenv "GOPATH" my-project-path))
|
||||
(eval . (message "Project directory set to `%s'." my-project-path)))))
|
@ -95,13 +95,14 @@ func Main() {
|
||||
}
|
||||
nserv.Hooks = hooks
|
||||
}
|
||||
|
||||
var frontends []frontend.Frontend
|
||||
var db database.Database
|
||||
for _, fconf := range conf.Frontends {
|
||||
var f frontend.Frontend
|
||||
f, err = frontend.NewHTTPFrontend(fconf, db)
|
||||
if err == nil {
|
||||
go f.Serve()
|
||||
frontends = append(frontends, f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,6 +122,15 @@ func Main() {
|
||||
log.Infof("reloading config: %s", cfgFname)
|
||||
nserv.ReloadServer(conf.NNTP)
|
||||
nserv.ReloadFeeds(conf.Feeds)
|
||||
for idx := range frontends {
|
||||
f := frontends[idx]
|
||||
for i := range conf.Frontends {
|
||||
c := conf.Frontends[i]
|
||||
if c != nil && c.Name() == f.Name() {
|
||||
f.Reload(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Errorf("failed to reload config: %s", err)
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type FrontendConfig struct {
|
||||
// bind to address
|
||||
BindAddr string `json:"bind"`
|
||||
@ -13,6 +17,10 @@ type FrontendConfig struct {
|
||||
Middleware *MiddlewareConfig `json:"middleware"`
|
||||
}
|
||||
|
||||
func (cfg *FrontendConfig) Name() string {
|
||||
return fmt.Sprintf("frontend-%s", cfg.BindAddr)
|
||||
}
|
||||
|
||||
// default Frontend Configuration
|
||||
var DefaultFrontendConfig = FrontendConfig{
|
||||
BindAddr: "127.0.0.1:18888",
|
||||
|
@ -27,6 +27,9 @@ type Frontend interface {
|
||||
|
||||
// reload config
|
||||
Reload(c *config.FrontendConfig)
|
||||
|
||||
// get frontend name
|
||||
Name() string
|
||||
}
|
||||
|
||||
// create a new http frontend give frontend config
|
||||
|
@ -33,6 +33,10 @@ type httpFrontend struct {
|
||||
db database.Database
|
||||
}
|
||||
|
||||
func (f *httpFrontend) Name() string {
|
||||
return fmt.Sprintf("frontend-%s", f.addr)
|
||||
}
|
||||
|
||||
// reload http frontend
|
||||
// reloads middleware
|
||||
func (f *httpFrontend) Reload(c *config.FrontendConfig) {
|
||||
|
@ -97,6 +97,7 @@ func (sd *socksDialer) Dial(remote string) (c net.Conn, err error) {
|
||||
}).Warn("connect via socks proxy failed")
|
||||
c.Close()
|
||||
c = nil
|
||||
err = errors.New("could not connect via socks proxy")
|
||||
}
|
||||
} else {
|
||||
// error reading reply
|
||||
@ -106,6 +107,7 @@ func (sd *socksDialer) Dial(remote string) (c net.Conn, err error) {
|
||||
}).Error("failed to read socks response ", err)
|
||||
c.Close()
|
||||
c = nil
|
||||
err = errors.New("socks proxy gave no reply")
|
||||
}
|
||||
} else {
|
||||
if err == nil {
|
||||
|
@ -622,6 +622,10 @@ func (c *v1Conn) printfLine(format string, args ...interface{}) error {
|
||||
}
|
||||
|
||||
func (c *v1Conn) readline() (line string, err error) {
|
||||
if c.C == nil || c.C.R == nil {
|
||||
err = errors.New("connection closed")
|
||||
return
|
||||
}
|
||||
line, err = c.C.ReadLine()
|
||||
log.WithFields(log.Fields{
|
||||
"pkg": "nntp-conn",
|
||||
|
Reference in New Issue
Block a user