Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ applied to `nginx`.
security profile, as there is no web app to exploit.
- **Optimized Matching**: Regex rules are evaluated once per request using
NGINX's `map` directive. Enable `pcre_jit` for the best performance.
- **Question Detection**: Queries ending with a question mark are automatically routed to ChatGPT.

## Installation

Expand Down
11 changes: 11 additions & 0 deletions cmd/sea/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,14 @@ func TestGenerateNginx(t *testing.T) {
t.Errorf("generated config missing error log disable: %s", out)
}
}

func TestQuestionMarkRulePresent(t *testing.T) {
cfg := Config{}
out, err := generateNginx(cfg)
if err != nil {
t.Fatalf("failed to generate nginx: %v", err)
}
if !strings.Contains(out, "\\?\\s*$") {
t.Errorf("question mark routing rule missing: %s", out)
}
}
2 changes: 2 additions & 0 deletions cmd/sea/nginx.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ map $arg_q $sea_dest {
~*(?i)^(style|proofread|review|listen|plot|graph|chart|map)\b chatgpt;
~*(?i)^(diagram|simulate|predict|forecast|estimate|answer|reply)\b chatgpt;
~*(?i)^(respond|inquire|query|request|discuss)\b chatgpt;
# route any query ending with a question mark to ChatGPT
~*(?i)\?\s*$ chatgpt;
# explicit wiki keywords
~*(?i)\bwikipedia\b|\bwiki\b wikipedia;
{{- range .CustomKeywords }}
Expand Down
4 changes: 4 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ map $arg_q $sea_dest {
~*(?i)^(style|proofread|review|listen|plot|graph|chart|map)\b chatgpt;
~*(?i)^(diagram|simulate|predict|forecast|estimate|answer|reply)\b chatgpt;
~*(?i)^(respond|inquire|query|request|discuss)\b chatgpt;
# route any query ending with a question mark to ChatGPT
~*(?i)\?\s*$ chatgpt;
# explicit wiki keywords
~*(?i)\bwikipedia\b|\bwiki\b wikipedia;
default google;
Expand All @@ -45,6 +47,8 @@ server {
listen 80;
listen [::]:80;
server_name search.localhost;
access_log off;
error_log /dev/null crit;

location / {
return 302 $sea_target;
Expand Down