kfix / MacPin

a webapp container & site specific browser made from WebKit.swift and JavaScriptCore
GNU General Public License v3.0
331 stars 27 forks source link

implement host redirection via in-app VPN or socket-filter #28

Open kfix opened 7 years ago

kfix commented 7 years ago

build some VPN support in for doing ad-hoc redirection/filtering of specific hosts' WebView requests and/or their DNS resolutions https://github.com/lshuzhi/SimpleTunnelMacos https://github.com/liruqi/Mume-iOS https://developer.apple.com/reference/networkextension/netunnelprovidermanager

Chrome does this with --host-rules=MAP <src-pattern> <host:port>, EXCLUDE <pattern> https://github.com/electron/electron/blob/master/docs/api/chrome-command-line-switches.md#--host-rulesrules

kfix commented 7 years ago

a basic socket-redirection approach: https://lists.apple.com/archives/darwin-kernel/2013/Jul/msg00007.html https://developer.apple.com/reference/kernel/sf_connect_out_func?language=objc https://developer.apple.com/library/content/documentation/Darwin/Conceptual/NKEConceptual/socket_nke/socket_nke.html https://github.com/ludup/hypersocket-osx

hmm, doesn't provide way to isolate to a specific WebKit-utilizing bundle name, could only attach redirector to all WebKit apps: https://stackoverflow.com/questions/35684211/how-to-identify-a-process-in-c-within-a-mac-network-kernel-extension-socket-fil

https://github.com/iadgov/netfil

johndpope commented 5 years ago

I've come across this ticket - because I'm looking for a way to host a website completely offline using a HAR / http archive file.

I think this may parallel the efforts of this ticket - because you could modify the payloads of captured har file and potentially hack things if need be in swift for more granularity. I built this codebase for another project - but could be cherry picked. https://github.com/johndpope/HAR-playback-swift

in one line of code you can pass a har file which allows you to swizzle / intercept http requests and modify payload of urls.

related https://github.com/HTTPArchive/httparchive.org/issues/96

UPDATE Never mind - I find this which suits my needs. https://github.com/webrecorder/webrecorderplayer-electron/releases/tag/v1.5.0