Changeset 147 in code for trunk


Ignore:
Timestamp:
Mar 18, 2024, 1:23:54 AM (15 months ago)
Author:
Izuru Yakumo
Message:

コードのリファクタリングが完了しました

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

Location:
trunk
Files:
14 added
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile

    r146 r147  
    2020
    2121yukari: vendor
    22         $(GO) build $(GOFLAGS) -o $@
     22        $(GO) build $(GOFLAGS) ./cmd/yukari
    2323clean:
    2424        $(RM) -f yukari
  • trunk/README.md

    r142 r147  
    1 # Yukari
     1# Yukari's Gap
    22
    3 Web content sanitizer proxy as a service, fork of [MortyProxy](https://github.com/asciimoo/morty) with some suggestions from the issue tracker applied, named after [Yes, that Gap Youkai](https://en.touhouwiki.net/wiki/Yukari_Yakumo)
     3Web content sanitizer proxy as a service, fork of [MortyProxy](https://github.com/asciimoo/morty) with some suggestions from the issue tracker applied, named after [the youkai you shouldn't ever come near](https://en.touhouwiki.net/wiki/Yukari_Yakumo)
    44
    5 Yukari rewrites web pages to exclude malicious HTML tags and attributes. It also replaces external resource references to prevent third party information leaks.
     5Yukari's Gap rewrites web pages to exclude malicious HTML tags and attributes. It also replaces external resource references to prevent third party information leaks.
    66
    7 The main goal of yukari is to provide a result proxy for [searx](https://asciimoo.github.com/searx/), but it can be used as a standalone sanitizer service too.
     7The main goal of this tool is to provide a result proxy for [searx](https://asciimoo.github.com/searx/), but it can be used as a standalone sanitizer service too.
    88
    99Features:
    1010
    11  - HTML sanitization
    12  - Rewrites HTML/CSS external references to locals
    13  - JavaScript blocking
    14  - No Cookies forwarded
    15  - No Referrers
    16  - No Caching/Etag
    17  - Supports GET/POST forms and IFrames
    18  - Optional HMAC URL verifier key to prevent service abuse
     11* HTML sanitization
     12* Rewrites HTML/CSS external references to locals
     13* JavaScript blocking
     14* No Cookies forwarded
     15* No Referrers
     16* No Caching/Etag
     17* Supports GET/POST forms and IFrames
     18* Optional HMAC URL verifier key to prevent service abuse
    1919
    2020
    2121## Installation and setup
    22 Requirement: Go version 1.10 or higher.
     22Requirement: Go version 1.16 or higher.
    2323
    2424```
  • trunk/config/config.go

    r142 r147  
    22
    33import (
    4         "os"
     4        "gopkg.in/ini.v1"
    55)
    66
    7 type Config struct {
     7var Config struct {
    88        Debug          bool
    99        ListenAddress  string
     
    1717}
    1818
    19 var DefaultConfig *Config
     19func readConfig(file string) error {
     20        cfg, err := ini.Load(file)
     21        if err != nil {
     22                return err
     23        }
     24        Config.Debug, _ = cfg.Section("yukari").Key("debug").Bool()
     25        Config.ListenAddress = cfg.Section("yukari").Key("listen").String()
     26        Config.Key = cfg.Section("yukari").Key("key").String()
     27        Config.IPV6, _ = cfg.Section("yukari").Key("ipv6").Bool()
     28        Config.RequestTimeout, _ = cfg.Section("yukari").Key("timeout").Uint()
     29        Config.FollowRedirect, _ = cfg.Section("yukari").Key("followredirect").Bool()
     30        Config.MaxConnsPerHost, _ = cfg.Section("yukari").Key("max_conns_per_host").Uint()
     31        Config.UrlParameter = cfg.Section("yukari").Key("urlparam").String()
     32        Config.HashParameter = cfg.Section("yukari").Key("hashparam").String()
    2033
    21 func init() {
    22         default_listen_addr := os.Getenv("YUKARI_ADDRESS")
    23         if default_listen_addr == "" {
    24                 default_listen_addr = "127.0.0.1:3000"
    25         }
    26         default_url_parameter := os.Getenv("YUKARI_URL_PARAM")
    27         if default_url_parameter == "" {
    28                 default_url_parameter = "yukariurl"
    29         }
    30         default_hash_parameter := os.Getenv("YUKARI_HASH_PARAM")
    31         if default_hash_parameter == "" {
    32                 default_hash_parameter = "yukarihash"
    33         }
    34         default_key := os.Getenv("YUKARI_KEY")
    35         DefaultConfig = &Config{
    36                 Debug:          os.Getenv("DEBUG") != "false",
    37                 ListenAddress:  default_listen_addr,
    38                 Key:            default_key,
    39                 IPV6:           true,
    40                 RequestTimeout: 5,
    41                 FollowRedirect: false,
    42                 MaxConnsPerHost: 4,
    43                 UrlParameter: default_url_parameter,
    44                 HashParameter: default_hash_parameter,
    45         }
     34        return nil
    4635}
  • trunk/go.mod

    r142 r147  
    11module marisa.chaotic.ninja/yukari
    22
    3 go 1.14
     3go 1.16
    44
    55require (
     6        github.com/stretchr/testify v1.9.0 // indirect
    67        github.com/valyala/fasthttp v1.34.0
    78        golang.org/x/net v0.7.0
    89        golang.org/x/text v0.7.0
     10        gopkg.in/ini.v1 v1.67.0
    911)
  • trunk/go.sum

    r140 r147  
    11github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
    22github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
     3github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
     4github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
     5github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
    36github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U=
    47github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
     8github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
     9github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
     10github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
     11github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
     12github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
     13github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
     14github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
     15github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
     16github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
     17github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
     18github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
    519github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
    620github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
     
    4458golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
    4559golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
     60gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
     61gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
     62gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
     63gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
     64gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
     65gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
  • trunk/yukari.1

    r142 r147  
    1 .TH MORTY "1" "2018" "yukari" "User Commands"
    2 .SH NAME
    3 yukari \- Privacy aware web content sanitizer proxy as a service
    4 .SH SYNOPSIS
    5 .B yukari
    6 .RI [ OPTIONS ]
    7 .br
    8 .SH DESCRIPTION
    9 Yukari rewrites web pages to exclude malicious HTML tags and attributes. It
    10 also replaces external resource references to prevent third party
     1.Dd $Mdocdate$
     2.Dt YUKARI 1
     3.Os
     4.Sh NAME
     5.Nm yukari
     6.Nd Privacy-aware Web Content Sanitizer Proxy As A Service (WCSPAAS)
     7.Sh SYNOPSIS
     8.Nm
     9.Op Fl f Ar string
     10.Op Fl proxy Ar string
     11.Op Fl proxyenv Ar bool
     12.Op Fl socks5 Ar string
     13.Op Fl version
     14.Sh DESCRIPTION
     15Yukari's Gap rewrites web pages to exclude malicious HTML tags and attributes.
     16It also replaces external resource references in order to prevent third-party
    1117information leaks.
    12 .sp
    13 The main goal of yukari is to provide a result proxy for searx, but it can be
    14 used as a standalone sanitizer service too.
    15 .SH OPTIONS
    16 .HP
    17 \fB\-ipv6\fR
    18 .IP
    19 Allow IPv6 HTTP requests
    20 .HP
    21 \fB\-key\fR string
    22 .IP
    23 HMAC url validation key (hexadecimal encoded) \- leave blank to disable
    24 .HP
    25 \fB\-listen\fR string
    26 .IP
    27 Listen address (default "127.0.0.1:3000")
    28 .HP
    29 \fB\-timeout\fR uint
    30 .IP
    31 Request timeout (default 2)
    32 .HP
    33 \fB\-version\fR
    34 .IP
    35 Show version
    36 .SH BUGS
    37 Bugs or suggestions? Visit the issue tracker at
    38 https://git.chaotic.ninja/yakumo.izuru/yukari/issues.
    39 .SH SEE ALSO
    40 .BR searx (1)
    41 .SH LICENSE
    42 Copyright 2023-present Izuru Yakumo <yakumo.izuru@chaotic.ninja>
    43 .br
    44 Copyright 2016-2018 Adam Tauber <asciimoo@gmail.com>
    45 .br
    46 Copyright 2016 Alexandre Flament <alex@al-f.net>
    47 .sp
    48 This program is free software: you can redistribute it and/or modify it under
    49 the terms of the GNU Affero General Public License as published by the Free
    50 Software Foundation, either version 3 of the License, or (at your option) any
    51 later version.
    52 .sp
     18.Pp
     19The main goal of Yukari's Gap is to provide a result proxy for SearX, but it
     20can be used as a standalone sanitizer service, too.
     21.Sh OPTIONS
     22.Bl -tag -width Ds
     23.It Fl f Ar path
     24Load configuration file from path
     25.It Fl proxy Ar string
     26Use the specified HTTP proxy (ie: [user:pass@]hostname:port),
     27this overrides the
     28.Fl socks5
     29option and the IPv6 setting
     30.It Fl proxyenv Ar bool
     31Use a HTTP proxy as set in the environment (such as
     32.Ev HTTP_PROXY ,
     33.Ev HTTPS_PROXY ,
     34.Ev NO_PROXY
     35).
     36Overrides the
     37.Fl proxy ,
     38.Fl socks5 ,
     39flags and the IPv6 setting
     40.It Fl socks5 Ar string
     41Use a SOCKS5 proxy (ie: hostname:port), this
     42overrides the IPv6 setting
     43.El
     44.Sh SEE ALSO
     45.Xr SearX 1
     46.Sh AUTHORS
     47.An Adam Tauber Aq Mt asciimoo@gmail.com
     48.An Alexandre Flament Aq Mt alex@al-f.net
     49.Sh MAINTAINERS
     50.An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja
     51.Sh BUGS
     52Bugs or suggestions?
     53Send an email to
     54.Aq Mt yukari-dev@chaotic.ninja
     55.Sh LICENSE
     56This program is free software: you can redistribute it and/or modify it
     57under the terms of the GNU Affero General Public License as published
     58by the Free Software Foundation, either version 3 of the License, or
     59(at your option) any later version.
     60.Pp
    5361This program is distributed in the hope that it will be useful, but WITHOUT ANY
    5462WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    55 PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
    56 details.
    57 .sp
    58 You should have received a copy of the GNU Affero General Public License along
    59 with this program. If not, see <http://www.gnu.org/licenses/>.
     63PARTICULAR PURPOSE.
     64See the GNU Affero General Public License for more details.
Note: See TracChangeset for help on using the changeset viewer.