diff options
Diffstat (limited to 'gopher')
-rw-r--r-- | gopher/client.go | 6 | ||||
-rw-r--r-- | gopher/gophermap/parse.go | 6 | ||||
-rw-r--r-- | gopher/gophermap/parse_test.go | 4 | ||||
-rw-r--r-- | gopher/request.go | 8 | ||||
-rw-r--r-- | gopher/request_test.go | 2 | ||||
-rw-r--r-- | gopher/response.go | 70 | ||||
-rw-r--r-- | gopher/serve.go | 14 |
7 files changed, 55 insertions, 55 deletions
diff --git a/gopher/client.go b/gopher/client.go index 8f5ca81..fad9413 100644 --- a/gopher/client.go +++ b/gopher/client.go @@ -6,7 +6,7 @@ import ( "io" "net" - "tildegit.org/tjp/gus" + sr "tildegit.org/tjp/sliderule" ) // Client is used for sending gopher requests and producing the responses. @@ -17,7 +17,7 @@ import ( type Client struct{} // RoundTrip sends a single gopher request and returns its response. -func (c Client) RoundTrip(request *gus.Request) (*gus.Response, error) { +func (c Client) RoundTrip(request *sr.Request) (*sr.Response, error) { if request.Scheme != "gopher" && request.Scheme != "" { return nil, errors.New("non-gopher protocols not supported") } @@ -51,5 +51,5 @@ func (c Client) RoundTrip(request *gus.Request) (*gus.Response, error) { return nil, err } - return &gus.Response{Body: bytes.NewBuffer(response)}, nil + return &sr.Response{Body: bytes.NewBuffer(response)}, nil } diff --git a/gopher/gophermap/parse.go b/gopher/gophermap/parse.go index 302aef0..17fe833 100644 --- a/gopher/gophermap/parse.go +++ b/gopher/gophermap/parse.go @@ -7,8 +7,8 @@ import ( "fmt" "io" - "tildegit.org/tjp/gus" - "tildegit.org/tjp/gus/gopher" + sr "tildegit.org/tjp/sliderule" + "tildegit.org/tjp/sliderule/gopher" ) // Parse reads a gophermap document from a reader. @@ -30,7 +30,7 @@ func Parse(input io.Reader) (gopher.MapDocument, error) { return nil, InvalidLine(num) } - item := gopher.MapItem{Type: gus.Status(line[0])} + item := gopher.MapItem{Type: sr.Status(line[0])} spl := bytes.Split(line[1:len(line)-2], []byte{'\t'}) if len(spl) != 4 { diff --git a/gopher/gophermap/parse_test.go b/gopher/gophermap/parse_test.go index 0e5c09e..51a430e 100644 --- a/gopher/gophermap/parse_test.go +++ b/gopher/gophermap/parse_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "tildegit.org/tjp/gus/gopher" - "tildegit.org/tjp/gus/gopher/gophermap" + "tildegit.org/tjp/sliderule/gopher" + "tildegit.org/tjp/sliderule/gopher/gophermap" ) func TestParse(t *testing.T) { diff --git a/gopher/request.go b/gopher/request.go index ef68438..4125af3 100644 --- a/gopher/request.go +++ b/gopher/request.go @@ -8,11 +8,11 @@ import ( "path" "strings" - "tildegit.org/tjp/gus" + sr "tildegit.org/tjp/sliderule" ) -// ParseRequest parses a gopher protocol request into a gus.Request object. -func ParseRequest(rdr io.Reader) (*gus.Request, error) { +// ParseRequest parses a gopher protocol request into a sliderule.Request object. +func ParseRequest(rdr io.Reader) (*sr.Request, error) { selector, search, err := readFullRequest(rdr) if err != nil { return nil, err @@ -22,7 +22,7 @@ func ParseRequest(rdr io.Reader) (*gus.Request, error) { selector = "/" + selector } - return &gus.Request{ + return &sr.Request{ URL: &url.URL{ Scheme: "gopher", Path: path.Clean(strings.TrimSuffix(selector, "\r\n")), diff --git a/gopher/request_test.go b/gopher/request_test.go index 1ab7801..74030c6 100644 --- a/gopher/request_test.go +++ b/gopher/request_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "tildegit.org/tjp/gus/gopher" + "tildegit.org/tjp/sliderule/gopher" ) func TestParseRequest(t *testing.T) { diff --git a/gopher/response.go b/gopher/response.go index c600b10..566623f 100644 --- a/gopher/response.go +++ b/gopher/response.go @@ -6,49 +6,49 @@ import ( "io" "sync" - "tildegit.org/tjp/gus" + sr "tildegit.org/tjp/sliderule" ) // The Canonical gopher item types. const ( - TextFileType gus.Status = '0' - MenuType gus.Status = '1' - CSOPhoneBookType gus.Status = '2' - ErrorType gus.Status = '3' - MacBinHexType gus.Status = '4' - DosBinType gus.Status = '5' - UuencodedType gus.Status = '6' - SearchType gus.Status = '7' - TelnetSessionType gus.Status = '8' - BinaryFileType gus.Status = '9' - MirrorServerType gus.Status = '+' - GifFileType gus.Status = 'g' - ImageFileType gus.Status = 'I' - Telnet3270Type gus.Status = 'T' + TextFileType sr.Status = '0' + MenuType sr.Status = '1' + CSOPhoneBookType sr.Status = '2' + ErrorType sr.Status = '3' + MacBinHexType sr.Status = '4' + DosBinType sr.Status = '5' + UuencodedType sr.Status = '6' + SearchType sr.Status = '7' + TelnetSessionType sr.Status = '8' + BinaryFileType sr.Status = '9' + MirrorServerType sr.Status = '+' + GifFileType sr.Status = 'g' + ImageFileType sr.Status = 'I' + Telnet3270Type sr.Status = 'T' ) // The gopher+ types. const ( - BitmapType gus.Status = ':' - MovieFileType gus.Status = ';' - SoundFileType gus.Status = '<' + BitmapType sr.Status = ':' + MovieFileType sr.Status = ';' + SoundFileType sr.Status = '<' ) // The various non-canonical gopher types. const ( - DocumentType gus.Status = 'd' - HTMLType gus.Status = 'h' - InfoMessageType gus.Status = 'i' - PngImageFileType gus.Status = 'p' - RtfDocumentType gus.Status = 'r' - WavSoundFileType gus.Status = 's' - PdfDocumentType gus.Status = 'P' - XmlDocumentType gus.Status = 'X' + DocumentType sr.Status = 'd' + HTMLType sr.Status = 'h' + InfoMessageType sr.Status = 'i' + PngImageFileType sr.Status = 'p' + RtfDocumentType sr.Status = 'r' + WavSoundFileType sr.Status = 's' + PdfDocumentType sr.Status = 'P' + XmlDocumentType sr.Status = 'X' ) // MapItem is a single item in a gophermap. type MapItem struct { - Type gus.Status + Type sr.Status Display string Selector string Hostname string @@ -70,8 +70,8 @@ func (mi MapItem) String() string { // Response builds a response which contains just this single MapItem. // // Meta in the response will be a pointer to the MapItem. -func (mi *MapItem) Response() *gus.Response { - return &gus.Response{ +func (mi *MapItem) Response() *sr.Response { + return &sr.Response{ Status: mi.Type, Meta: &mi, Body: bytes.NewBufferString(mi.String() + ".\r\n"), @@ -89,8 +89,8 @@ func (md MapDocument) String() string { // Response builds a gopher response containing the gophermap. // // Meta will be the MapDocument itself. -func (md MapDocument) Response() *gus.Response { - return &gus.Response{ +func (md MapDocument) Response() *sr.Response { + return &sr.Response{ Status: DocumentType, Meta: md, Body: md.serialize(), @@ -119,12 +119,12 @@ func Error(err error) *MapItem { // File builds a minimal response delivering a file's contents. // // Meta is nil and Status is 0 in this response. -func File(status gus.Status, contents io.Reader) *gus.Response { - return &gus.Response{Status: status, Body: contents} +func File(status sr.Status, contents io.Reader) *sr.Response { + return &sr.Response{Status: status, Body: contents} } // NewResponseReader produces a reader which supports reading gopher protocol responses. -func NewResponseReader(response *gus.Response) gus.ResponseReader { +func NewResponseReader(response *sr.Response) sr.ResponseReader { return &responseReader{ Response: response, once: &sync.Once{}, @@ -132,7 +132,7 @@ func NewResponseReader(response *gus.Response) gus.ResponseReader { } type responseReader struct { - *gus.Response + *sr.Response reader io.Reader once *sync.Once } diff --git a/gopher/serve.go b/gopher/serve.go index 572fa55..bad7935 100644 --- a/gopher/serve.go +++ b/gopher/serve.go @@ -8,14 +8,14 @@ import ( "net" "strings" - "tildegit.org/tjp/gus" - "tildegit.org/tjp/gus/internal" - "tildegit.org/tjp/gus/logging" + sr "tildegit.org/tjp/sliderule" + "tildegit.org/tjp/sliderule/internal" + "tildegit.org/tjp/sliderule/logging" ) type gopherServer struct { internal.Server - handler gus.Handler + handler sr.Handler } func (gs gopherServer) Protocol() string { return "GOPHER" } @@ -26,9 +26,9 @@ func NewServer( hostname string, network string, address string, - handler gus.Handler, + handler sr.Handler, errLog logging.Logger, -) (gus.Server, error) { +) (sr.Server, error) { gs := &gopherServer{handler: handler} if strings.IndexByte(hostname, ':') < 0 { @@ -45,7 +45,7 @@ func NewServer( } func (gs *gopherServer) handleConn(conn net.Conn) { - var response *gus.Response + var response *sr.Response request, err := ParseRequest(conn) if err != nil { response = Error(errors.New("Malformed request.")).Response() |