diff --git a/Dockerfile b/Dockerfile index c1bb6db..c41b5a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,17 +11,17 @@ RUN go mod download # Copy source and build COPY . . -RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /gosearch ./cmd/searxng-go +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /kafka ./cmd/searxng-go # Runtime stage FROM alpine:3.21 RUN apk add --no-cache ca-certificates tzdata -COPY --from=builder /gosearch /usr/local/bin/gosearch -COPY config.example.toml /etc/gosearch/config.example.toml +COPY --from=builder /kafka /usr/local/bin/kafka +COPY config.example.toml /etc/kafka/config.example.toml EXPOSE 8080 -ENTRYPOINT ["gosearch"] -CMD ["-config", "/etc/gosearch/config.toml"] +ENTRYPOINT ["kafka"] +CMD ["-config", "/etc/kafka/config.toml"] diff --git a/README.md b/README.md index b6c5e36..2f0868f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# gosearch +# kafka A privacy-respecting, open metasearch engine written in Go. SearXNG-compatible API with an HTML frontend, designed to be fast, lightweight, and deployable anywhere. @@ -12,7 +12,7 @@ A privacy-respecting, open metasearch engine written in Go. SearXNG-compatible A - **Valkey cache** — optional Redis-compatible caching with configurable TTL - **Rate limiting** — three layers: per-IP, burst, and global (all disabled by default) - **CORS** — configurable origins for browser-based clients -- **OpenSearch** — browsers can add gosearch as a search engine from the address bar +- **OpenSearch** — browsers can add kafka as a search engine from the address bar - **Graceful degradation** — individual engine failures don't kill the whole search - **Docker** — multi-stage build, ~20MB runtime image - **NixOS** — native NixOS module with systemd service @@ -23,7 +23,7 @@ A privacy-respecting, open metasearch engine written in Go. SearXNG-compatible A ```bash git clone https://git.ashisgreat.xyz/penal-colony/gosearch.git -cd gosearch +cd kafka go build ./cmd/searxng-go ./searxng-go -config config.toml ``` @@ -41,28 +41,28 @@ docker compose up -d Add to your flake inputs: ```nix -inputs.gosearch.url = "git+https://git.ashisgreat.xyz/penal-colony/gosearch.git"; +inputs.kafka.url = "git+https://git.ashisgreat.xyz/penal-colony/gosearch.git"; ``` Enable in your configuration: ```nix -imports = [ inputs.gosearch.nixosModules.default ]; +imports = [ inputs.kafka.nixosModules.default ]; -services.gosearch = { +services.kafka = { enable = true; openFirewall = true; baseUrl = "https://search.example.com"; - # config = "/etc/gosearch/config.toml"; # default + # config = "/etc/kafka/config.toml"; # default }; ``` Write your config: ```bash -sudo mkdir -p /etc/gosearch -sudo cp config.example.toml /etc/gosearch/config.toml -sudo $EDITOR /etc/gosearch/config.toml +sudo mkdir -p /etc/kafka +sudo cp config.example.toml /etc/kafka/config.toml +sudo $EDITOR /etc/kafka/config.toml ``` Deploy: diff --git a/config.example.toml b/config.example.toml index f5cfa0b..df77184 100644 --- a/config.example.toml +++ b/config.example.toml @@ -1,4 +1,4 @@ -# gosearch configuration +# kafka configuration # Copy to config.toml and adjust as needed. # Environment variables are used as fallbacks when a config field is empty/unset. @@ -10,7 +10,7 @@ port = 8080 http_timeout = "10s" # Public base URL for OpenSearch XML (env: BASE_URL) -# Set this so browsers can add gosearch as a search engine. +# Set this so browsers can add kafka as a search engine. # Example: "https://search.example.com" base_url = "" diff --git a/docker-compose.yml b/docker-compose.yml index 409edfd..98eae96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,16 @@ -# Docker Compose for gosearch + Valkey +# Docker Compose for kafka + Valkey # # Usage: # cp config.example.toml config.toml # edit as needed # docker compose up -d services: - gosearch: + kafka: build: . ports: - "8080:8080" volumes: - - ./config.toml:/etc/gosearch/config.toml:ro + - ./config.toml:/etc/kafka/config.toml:ro depends_on: valkey: condition: service_healthy diff --git a/flake.nix b/flake.nix index a189428..ca7c684 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "gosearch — privacy-respecting, open metasearch engine"; + description = "kafka — privacy-respecting, open metasearch engine"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; @@ -17,7 +17,7 @@ in { default = pkgs.buildGoModule { - pname = "gosearch"; + pname = "kafka"; version = "0.1.0"; src = ./.; @@ -32,7 +32,7 @@ meta = with pkgs.lib; { description = "Privacy-respecting, open metasearch engine"; - homepage = "https://git.ashisgreat.xyz/penal-colony/gosearch"; + homepage = "https://git.ashisgreat.xyz/penal-colony/kafka"; license = licenses.mit; platforms = platforms.linux ++ platforms.darwin; }; @@ -41,16 +41,16 @@ nixosModules.default = { config, lib, pkgs, ... }: let - cfg = config.services.gosearch; + cfg = config.services.kafka; in { - options.services.gosearch = { - enable = lib.mkEnableOption "gosearch metasearch engine"; + options.services.kafka = { + enable = lib.mkEnableOption "kafka metasearch engine"; package = lib.mkOption { type = lib.types.package; default = self.packages.${pkgs.system}.default; - description = "gosearch package to use."; + description = "kafka package to use."; }; port = lib.mkOption { @@ -73,41 +73,41 @@ config = lib.mkOption { type = lib.types.path; - default = "/etc/gosearch/config.toml"; + default = "/etc/kafka/config.toml"; description = "Path to config.toml file."; }; user = lib.mkOption { type = lib.types.str; - default = "gosearch"; + default = "kafka"; description = "System user to run as."; }; group = lib.mkOption { type = lib.types.str; - default = "gosearch"; + default = "kafka"; description = "System group to run as."; }; stateDir = lib.mkOption { type = lib.types.path; - default = "/var/lib/gosearch"; + default = "/var/lib/kafka"; description = "State directory."; }; }; config = lib.mkIf cfg.enable { - users.users.${cfg.user} = lib.mkIf (cfg.user == "gosearch") { + users.users.${cfg.user} = lib.mkIf (cfg.user == "kafka") { isSystemUser = true; group = cfg.group; home = cfg.stateDir; createHome = true; }; - users.groups.${cfg.group} = lib.mkIf (cfg.group == "gosearch") { }; + users.groups.${cfg.group} = lib.mkIf (cfg.group == "kafka") { }; - systemd.services.gosearch = { - description = "gosearch metasearch engine"; + systemd.services.kafka = { + description = "kafka metasearch engine"; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; diff --git a/internal/cache/cache.go b/internal/cache/cache.go index 4e86efb..51d2cda 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -81,7 +81,7 @@ func (c *Cache) Get(ctx context.Context, key string) (contracts.SearchResponse, return contracts.SearchResponse{}, false } - fullKey := "gosearch:" + key + fullKey := "kafka:" + key data, err := c.client.Get(ctx, fullKey).Bytes() if err != nil { @@ -113,7 +113,7 @@ func (c *Cache) Set(ctx context.Context, key string, resp contracts.SearchRespon return } - fullKey := "gosearch:" + key + fullKey := "kafka:" + key if err := c.client.Set(ctx, fullKey, data, c.ttl).Err(); err != nil { c.logger.Warn("cache set failed", "key", fullKey, "error", err) } @@ -124,7 +124,7 @@ func (c *Cache) Invalidate(ctx context.Context, key string) { if !c.Enabled() { return } - fullKey := "gosearch:" + key + fullKey := "kafka:" + key c.client.Del(ctx, fullKey) } diff --git a/internal/config/config.go b/internal/config/config.go index e06d028..93b8d86 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -9,7 +9,7 @@ import ( "github.com/BurntSushi/toml" ) -// Config is the top-level configuration for the gosearch service. +// Config is the top-level configuration for the kafka service. type Config struct { Server ServerConfig `toml:"server"` Upstream UpstreamConfig `toml:"upstream"` diff --git a/internal/engines/bing.go b/internal/engines/bing.go index 1d46a26..1f091ca 100644 --- a/internal/engines/bing.go +++ b/internal/engines/bing.go @@ -43,7 +43,7 @@ func (e *BingEngine) Search(ctx context.Context, req contracts.SearchRequest) (c if err != nil { return contracts.SearchResponse{}, err } - httpReq.Header.Set("User-Agent", "gosearch/0.1 (compatible; +https://git.ashisgreat.xyz/penal-colony/gosearch)") + httpReq.Header.Set("User-Agent", "kafka/0.1 (compatible; +https://git.ashisgreat.xyz/penal-colony/gosearch)") resp, err := e.client.Do(httpReq) if err != nil { diff --git a/internal/engines/duckduckgo.go b/internal/engines/duckduckgo.go index ef291ad..3636275 100644 --- a/internal/engines/duckduckgo.go +++ b/internal/engines/duckduckgo.go @@ -38,7 +38,7 @@ func (e *DuckDuckGoEngine) Search(ctx context.Context, req contracts.SearchReque if err != nil { return contracts.SearchResponse{}, err } - httpReq.Header.Set("User-Agent", "gosearch/0.1 (compatible; +https://git.ashisgreat.xyz/penal-colony/gosearch)") + httpReq.Header.Set("User-Agent", "kafka/0.1 (compatible; +https://git.ashisgreat.xyz/penal-colony/gosearch)") resp, err := e.client.Do(httpReq) if err != nil { diff --git a/internal/engines/github.go b/internal/engines/github.go index 1a7cbbe..8d86516 100644 --- a/internal/engines/github.go +++ b/internal/engines/github.go @@ -40,7 +40,7 @@ func (e *GitHubEngine) Search(ctx context.Context, req contracts.SearchRequest) if err != nil { return contracts.SearchResponse{}, err } - httpReq.Header.Set("User-Agent", "gosearch/0.1") + httpReq.Header.Set("User-Agent", "kafka/0.1") httpReq.Header.Set("Accept", "application/vnd.github.v3+json") resp, err := e.client.Do(httpReq) diff --git a/internal/engines/qwant.go b/internal/engines/qwant.go index 853b501..67b5b99 100644 --- a/internal/engines/qwant.go +++ b/internal/engines/qwant.go @@ -90,7 +90,7 @@ func (e *QwantEngine) searchWebAPI(ctx context.Context, req contracts.SearchRequ if err != nil { return contracts.SearchResponse{}, err } - httpReq.Header.Set("User-Agent", "gosearch-go/0.1 (+https://github.com/ashie/gosearch)") + httpReq.Header.Set("User-Agent", "kafka/0.1 (compatible; +https://git.ashisgreat.xyz/penal-colony/gosearch)") resp, err := e.client.Do(httpReq) if err != nil { @@ -234,7 +234,7 @@ func (e *QwantEngine) searchWebLite(ctx context.Context, req contracts.SearchReq if err != nil { return contracts.SearchResponse{}, err } - httpReq.Header.Set("User-Agent", "gosearch-go/0.1 (+https://github.com/ashie/gosearch)") + httpReq.Header.Set("User-Agent", "kafka/0.1 (compatible; +https://git.ashisgreat.xyz/penal-colony/gosearch)") resp, err := e.client.Do(httpReq) if err != nil { diff --git a/internal/engines/reddit.go b/internal/engines/reddit.go index 9790fe0..8388152 100644 --- a/internal/engines/reddit.go +++ b/internal/engines/reddit.go @@ -37,7 +37,7 @@ func (e *RedditEngine) Search(ctx context.Context, req contracts.SearchRequest) if err != nil { return contracts.SearchResponse{}, err } - httpReq.Header.Set("User-Agent", "gosearch/0.1 (compatible; +https://git.ashisgreat.xyz/penal-colony/gosearch)") + httpReq.Header.Set("User-Agent", "kafka/0.1 (compatible; +https://git.ashisgreat.xyz/penal-colony/gosearch)") resp, err := e.client.Do(httpReq) if err != nil { diff --git a/internal/views/static/css/gosearch.css b/internal/views/static/css/kafka.css similarity index 99% rename from internal/views/static/css/gosearch.css rename to internal/views/static/css/kafka.css index 53171ed..ad794c4 100644 --- a/internal/views/static/css/gosearch.css +++ b/internal/views/static/css/kafka.css @@ -1,4 +1,4 @@ -/* gosearch — clean, minimal search engine CSS */ +/* kafka — clean, minimal search engine CSS */ /* Inspired by SearXNG's simple theme class conventions */ :root { diff --git a/internal/views/templates/base.html b/internal/views/templates/base.html index 9992d3c..10de540 100644 --- a/internal/views/templates/base.html +++ b/internal/views/templates/base.html @@ -6,19 +6,19 @@ - -