diff --git a/main.go b/main.go index 3260cde..79c37c9 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ import ( "9fans.net/go/plan9/client" "ollie/pkg/env" olog "ollie/pkg/log" + "olliesrv/server" ) const serviceName = "ollie" @@ -160,14 +161,14 @@ func runServer(sockPath, pidPath string) { os.WriteFile(pidPath, []byte(fmt.Sprintf("%d", os.Getpid())), 0644) //nolint:errcheck sink := olog.NewSink(os.Stdout, os.Stderr, olog.ParseLevel(os.Getenv("OLLIE_LOG"), olog.LevelWarn)) - var srvOpts []ServerOption + var srvOpts []server.Option if *strict { - srvOpts = append(srvOpts, WithStrict()) + srvOpts = append(srvOpts, server.WithStrict()) } if *yolo { - srvOpts = append(srvOpts, WithYolo()) + srvOpts = append(srvOpts, server.WithYolo()) } - srv := New(sink, srvOpts...) + srv := server.New(sink, srvOpts...) listener, err := net.Listen("unix", sockPath) if err != nil { diff --git a/server.go b/server/server.go similarity index 99% rename from server.go rename to server/server.go index b071df6..5dbbd7a 100644 --- a/server.go +++ b/server/server.go @@ -1,6 +1,6 @@ // 9P filesystem server for ollie sessions. // See doc comment below for filesystem layout. -package main +package server import ( "context" @@ -80,14 +80,14 @@ type Server struct { groups map[string]map[string]bool // group → set of members } -// ServerOption configures the 9P server. -type ServerOption func(*Server) +// Option configures the 9P server. +type Option func(*Server) -func WithStrict() ServerOption { return func(s *Server) { s.strict = true } } -func WithYolo() ServerOption { return func(s *Server) { s.yolo = true } } +func WithStrict() Option { return func(s *Server) { s.strict = true } } +func WithYolo() Option { return func(s *Server) { s.yolo = true } } // New creates a new Server. -func New(sink *olog.Sink, opts ...ServerOption) *Server { +func New(sink *olog.Sink, opts ...Option) *Server { memDir := defaultMemDir() os.MkdirAll(memDir, 0755) //nolint:errcheck transcriptDir := defaultTranscriptDir()