diff options
| author | bptato <nincsnevem662@gmail.com> | 2023-07-04 12:25:40 +0200 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2023-07-04 12:25:56 +0200 |
| commit | b96d8cc51a7f469eaa5804c24a8b45cc4d5b3756 (patch) | |
| tree | 0d1deb5281e233d6627a4cfde91732c34adbbc05 /src/display | |
| parent | e961b086d263022c3486a4742d1ab29331212c62 (diff) | |
| download | chawan-b96d8cc51a7f469eaa5804c24a8b45cc4d5b3756.tar.gz | |
Add proxy support
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/client.nim | 6 | ||||
| -rw-r--r-- | src/display/pager.nim | 41 |
2 files changed, 28 insertions, 19 deletions
diff --git a/src/display/client.nim b/src/display/client.nim index 5134f130..f7e89b78 100644 --- a/src/display/client.nim +++ b/src/display/client.nim @@ -566,7 +566,11 @@ proc newClient*(config: Config, dispatcher: Dispatcher): Client = result.config = config result.dispatcher = dispatcher result.attrs = getWindowAttributes(stdout) - result.loader = dispatcher.forkserver.newFileLoader() + let forkserver = dispatcher.forkserver + result.loader = forkserver.newFileLoader( + proxy = config.getProxy(), + acceptProxy = true + ) result.jsrt = newJSRuntime() result.jsrt.setInterruptHandler(interruptHandler, cast[pointer](result)) JS_SetModuleLoaderFunc(result.jsrt, normalizeModuleName, clientLoadJSModule, diff --git a/src/display/pager.nim b/src/display/pager.nim index c8d0b83e..2698550c 100644 --- a/src/display/pager.nim +++ b/src/display/pager.nim @@ -39,34 +39,35 @@ type SEARCH_B, ISEARCH_F, ISEARCH_B, GOTO_LINE Pager* = ref object + alerton: bool + alerts: seq[string] + askcursor: int askpromise*: Promise[bool] askprompt: string - askcursor: int - numload*: int - alerts: seq[string] - alerton: bool commandMode* {.jsget.}: bool + config: Config container*: Container + cookiejars: Table[string, CookieJar] dispatcher*: Dispatcher + display: FixedGrid + iregex: Result[Regex, string] lineedit*: Option[LineEdit] + linehist: array[LineMode, LineHistory] linemode*: LineMode - username: string - scommand*: string - config: Config + numload*: int + omnirules: seq[OmniRule] + procmap*: Table[Pid, Container] + proxy: URL + redraw*: bool regex: Opt[Regex] - iregex: Result[Regex, string] reverseSearch: bool + scommand*: string + siteconf: seq[SiteConfig] statusgrid*: FixedGrid + term*: Terminal tty: File - procmap*: Table[Pid, Container] unreg*: seq[(Pid, SocketStream)] - display: FixedGrid - redraw*: bool - term*: Terminal - linehist: array[LineMode, LineHistory] - siteconf: seq[SiteConfig] - omnirules: seq[OmniRule] - cookiejars: Table[string, CookieJar] + username: string jsDestructor(Pager) @@ -181,7 +182,8 @@ proc newPager*(config: Config, attrs: WindowAttributes, statusgrid: newFixedGrid(attrs.width), term: newTerminal(stdout, config, attrs), siteconf: config.getSiteConfig(ctx), - omnirules: config.getOmniRules(ctx) + omnirules: config.getOmniRules(ctx), + proxy: config.getProxy() ) return pager @@ -576,6 +578,7 @@ proc applySiteconf(pager: Pager, url: var URL): BufferConfig = var images: bool var charsets = pager.config.encoding.document_charset var userstyle = pager.config.css.stylesheet + var proxy = pager.proxy for sc in pager.siteconf: if sc.url.isSome and not sc.url.get.match($url): continue @@ -606,8 +609,10 @@ proc applySiteconf(pager: Pager, url: var URL): BufferConfig = if sc.stylesheet.isSome: userstyle &= "\n" userstyle &= sc.stylesheet.get + if sc.proxy.isSome: + proxy = sc.proxy.get return pager.config.getBufferConfig(url, cookiejar, headers, - referer_from, scripting, charsets, images, userstyle) + referer_from, scripting, charsets, images, userstyle, proxy) # Load request in a new buffer. proc gotoURL(pager: Pager, request: Request, prevurl = none(URL), |