Commit Graph
54 Commits
Author SHA1 Message Date
loyalsoldier 8ced9c330c Merge branch 'master' into v5 2021-04-03 09:15:19 +08:00
loyalsoldier 24948c6520 Merge branch 'master' into dev-wsimprovement 2021-03-28 08:40:05 +08:00
Shelikhoo f63ee69fcf added forwarder service 2021-03-20 21:59:30 +00:00
Shelikhoo 57b4214284 added definition for websocket browser forwarder 2021-03-20 21:58:07 +00:00
LoyalsoldierandGitHub e6aaa57def Feat: add queryStrategy option for DNS (#794) 2021-03-19 15:55:18 +08:00
loyalsoldier 8ea06ba81d Merge branch 'master' into v5 2021-02-24 17:26:17 +08:00
afb8385a7e Feat: routing and freedom outbound ignore Fake DNS (#696)
Turn off fake DNS for request sent from Routing and Freedom outbound.
Fake DNS now only apply to DNS outbound.
This is important for Android, where VPN service take over all system DNS
traffic and pass it to core.  "UseIp" option can be used in Freedom outbound
to avoid getting fake IP and fail connection.

Co-authored-by: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
2021-02-23 10:17:20 +08:00
ebbf31f07e improve commands (#648)
* stat show json refactor
> will show {} since scripts should expect it, its the json style of blank value

* combine statistics commands to one

* code optimize

* fix runtime flag

* remove json indent

* change overridden to override

* api bi -json

* convert stdin support
code optimize

* writeRow() code optimize
add stats tittle
revert back to restartlogger

* api log -restart

* follow log

* codeql

* move -json to shared flags

* flags optimize
* update flag descriptions
* change "-v" of "api bo" to duration
* change "-expire" of "tls cert" to days

* cmds short description optimize

* fix multiple log followers

* Format loader refactor
* "infra/conf/merge" refactor
* "LoadConfig" refactor
* add "infra/conf/mergers"
    * contribute to it will benifit `v2ray run`,`v2ray test`,`v2ray convert`
    * easily add new formats, by just adding a converter like json.FromTOML
* default format auto, to all cmds above
    * auto detect input format
    * mixed formats support
* better stdin behavior
    * don't wait if no content
    * don't use 'stdin:' placeholder
* `v2ray test` now behaves exactly the same with `v2ray run`, including stdin reading

* api ado, adi, rmo, rmi refactor
* support folders to files resolving, mixed formats
* remove remaining 'stdin:' placeholders

* fix tests
* os.Stdin.Stat() behaves different in platforms, removed

* code optimize

Co-authored-by: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
2021-02-21 23:02:42 +08:00
loyalsoldier d581fb9c00 Merge branch 'master' into v5 2021-02-17 08:07:12 +08:00
LoyalsoldierandGitHub f94dd11a8c Chore: change module name (#677) 2021-02-17 04:31:50 +08:00
loyalsoldier 02a8c41023 Merge branch 'master' into v5 2021-02-16 09:48:41 +08:00
38da831b75 Feature: Fake DNS support (#406)
* Add fake dns

A new config object "fake" in DnsObject for toggling fake dns function

Compare with sniffing, fake dns is not limited to http and tls traffic.
It works across all inbounds. For example, when dns request come
from one inbound, the local DNS server of v2ray will response with a
unique fake IP for every unique domain name. Then later on v2ray
received a request to one of the fake IP from any inbounds, it will
override the request destination with the previously saved domain.

By default, v2ray cache up to 65535 addresses. The old records will
be discarded bases on LRU. The fake IP will be 240.x.x.x

* fix an edge case when encounter a fake IP in use

* Move lru to common.cache package

* Added the necessary change to obtain request IP from sniffer

* Refactor the code so that it may stop depending on global variables in the future.

* Replace string manipulation code with more generic codes, hopefully this will work for both IPv4 and IPv6 networks.

* Try to use IPv4 version of address if possible

* Added Test Case for Fake Dns

* Added More Test Case for Fake Dns

* Stop user from creating a instance with LRU size more than subnet size, it will create a infinite loop

* Move Fake DNS to a separate package

* Generated Code for fakedns

* Encapsulate Fake DNS as a Instance wide service

* Added Support for metadata sniffer, which will be used for Fake DNS

* Dependency injection for fake dns

* Fake DNS As a Sniffer

* Remove stub object

* Remove global variable

* Update generated protobuf file for metadata only sniffing

* Apply Fake DNS config to session

* Loading for fake dns settings

* Bug fix

* Include fake dns in all

* Fix FakeDns Lint Condition

* Fix sniffer config

* Fix lint message

* Fix dependency resolution

* Fix fake dns not loaded as sniffer

* reduce ttl for fake dns

* Apply Coding Style

* Apply Coding Style

* Apply Coding Style

* Apply Coding Style

* Apply Coding Style

* Fix crashed when no fake dns

* Apply Coding Style

* Fix Fake DNS do not apply to UDP socket

* Fixed a bug prevent FakeDNS App Setting from become effective

* Fixed a caveat prevent FakeDNS App Setting from become effective

* Use log comparison to reduce in issue when it comes to really high value typical for ipv6 subnet

* Add build tag for fakedns

* Removal of FakeDNS specific logic at DNS client: making it a standard dns client

* Regenerate auto generated file

* Amended version of configure file

* Bug fixes for fakeDNS

* Bug fixes for fakeDNS

* Fix test: remove reference to removed attribute

* Test: fix codacy issue

* Conf: Remove old field support

* Test: fix codacy issue

* Change test scale for TestFakeDnsHolderCreateMappingAndRollOver

* Test: fix codacy issue

Co-authored-by: yuhan6665 <1588741+yuhan6665@users.noreply.github.com>
Co-authored-by: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
Co-authored-by: kslr <kslrwang@gmail.com>
2021-02-08 18:18:52 +08:00
JebbsandGitHub 2c5a714903 v5: Health Check & LeastLoad Strategy (#589)
* generate .pb.go

* health checker conf

* check logic

* implement ping

* fix check interval

* improve check results

* health check on add outbounds

* fix tests

* fix ping handler

* fix min rtt < 0

* random alive

* fix check all on add outbounds

* least load strategy

* conf codes optimize

* improve least load strategy

* improve health check on AddOutboundHandler

* cleanup results with scheduler
code optimize

* health ping timeout default 5s

* remove config of health ping round
round 1 seems to be good enough

* fix TestSimpleBalancer

* add TestLeastLoadBalancer

* add todos

* lint and test fix

* balancer fallback

* api health stats command

* add hc cmd to perform health checks
* rename 'health stats' cmd to hci
* many code optimizations

* fix typo

* select none if no match for baselines only config
> prev 'select 1' behavior can achieved by baselines+expected=1

* add LeastLoadStrategy tests

* don't select alive on no match, go to fallback

* api hci refactor
* more detailed info
* ready for future new strategies

* apply lint style

* refactor: strategies don't need ref of balancer

* change check interval unit to seconds
> to reduce influence caused by what is described by new added FIXME

* fix test

* RouterService->RoutingService

* Revert "generate .pb.go"

This reverts commit 0e6fa1be889470d0ad9692f7279da45c030e1919.

* make checks distributed
> but `api hc` is the exception

* BalancingStrategy interface optimize

* fix random selects unchecked

* upgrade cmd hci to bi & rename hc to bc
* bi shows all balancers, while hci shows only heath-check-enabled ones
* shows more info

* fix test

* api bi sort output

* update according to review

* remove checks on add outbound

* refactor: move health checker inside to strategy
* enables rounds setting for health ping
* restore the random behavior, no ping, no pick alive

> if future strategy based on HealthPing, just embed it like what LeastLoad does

* apply lint style

* code optimize

* fix typo

* update desc of bc bi

* ping with head
code optimize

* force rouds to 1 if checks not distributed

* leatload: select by standard deviations

* health ping refactor
* continuously applying results
* config is easier to understand
* checker interfaces simplifying

* add maxRTT config to filter away high delay nodes

* apply lint

* cost for leastload

* api bo to override balancer selecting

* fix health ping statistics & fix test

* check connectivity if ping fail

* add tolerance setting & more detailed bi output

* fix connectivity check

* optimize bi output

* should not put results when network is down

* fixes @_@

* mux optimize

* remove pause option of selecting overriding
> it causes data racing

* update bo desc

* fix potential racing

* simplify locking
* switch sync.Mutex to avoid potential racing
* add more tests
* code optimize

* code optimize

* fix connectivity check when url not set
2021-01-30 08:31:11 +08:00
V2Fly TeamandGitHub 66e203f156 DNS: refine skipRoutePick (#558) 2020-12-30 18:35:19 +08:00
ChinsyoandGitHub 231f5bf024 Add missing deprecation notice to deprecated code (#437) 2020-11-20 15:18:44 +08:00
loyalsoldier 784775f689 Refine code according to golangci-lint results 2020-10-11 19:22:46 +08:00
loyalsoldier b181045b0c Errorgen: support to run outside of GOPATH 2020-10-04 13:06:12 +08:00
Ye ZhihaoandGitHub 67f409de04 Stats: Implements blocking/non-blocking messaging of Channel (#250) 2020-10-03 03:06:32 +08:00
Vigilans fa37f82b89 Stats: Add ChannelConfig & Return error on subscription 2020-09-23 22:35:13 +08:00
KslrandGitHub 525d4e13a9 Merge pull request #197 from Vigilans/vigilans/stats-channel-runnable
Stats: Implement common.Runnable for Channel feature
2020-09-20 22:39:46 +08:00
Vigilans 4d5a4f4cb6 Routing: Implement Route interface as the routing result of Router 2020-09-18 17:30:59 +08:00
Vigilans 4fca2fe940 Implement common.Runnable for stats.Channel feature 2020-09-15 23:04:26 +08:00
Vigilans 5a497890e6 Routing Context: Fix GetUser() & Use string for Attributes Value 2020-09-13 00:34:35 +08:00
Vigilans 0406cd896b Add UnregisterChannel & Modify unregistering logic 2020-09-09 11:33:29 +08:00
LoyalsoldierandGitHub d7c99c901a Fix: app/stats.Manager does not implement features/stats.Manager (#171) 2020-09-09 11:26:23 +08:00
Vigilans bff96a7a52 Support Channel (Observer Pattern) in Stats Manager 2020-09-04 15:07:42 +08:00
Vigilans f9d37b724c Extract session information during routing as routing context 2020-09-04 11:32:19 +08:00
DuckSoft 1525712214 some typo fixes
note: there are other typos in external/ folder.
considering the fact that the folder "will be removed in future", I skipped those typos.
2020-07-17 18:09:24 +08:00
yuhan6665 886598542c Add stats counter for outbounds 2020-06-27 00:31:46 -04:00
Shelikhoo 220b783caa Align Timeout Value 2020-06-03 09:12:45 +08:00
Darien Raymond 9957c64b4a correctly propagate dns errors all the way through.
the internal dns system can correctly handle the cases where:
1) domain has no A or AAAA records
2) domain doesn't exist
fixes #1565
2019-02-21 13:43:48 +01:00
Darien Raymond 6b355ef461 fix a typo in local dns 2018-12-06 21:34:05 +01:00
Darien Raymond 21b3f66b8b fix IP parsing in local dns client 2018-12-06 20:11:45 +01:00
Darien Raymond 4104a86b6c use default dns resolver to prevent errors in android 2018-12-05 15:48:40 +01:00
Darien Raymond 28fa84ce69 API doc 2018-12-03 22:44:42 +01:00
Darien Raymond 480175691c comment 2018-11-22 22:49:45 +01:00
Darien Raymond 39a092b178 fix #1427 2018-11-22 19:07:49 +01:00
Darien Raymond bb1efdebd1 support querying either IPv4 or IPv6 dns 2018-11-19 20:42:02 +01:00
Darien Raymond c26a4b407b adjust default value of buffer size 2018-11-11 10:54:47 +01:00
Darien Raymond 73d3be424b prototype for balancing rules 2018-11-07 21:08:20 +01:00
Darien Raymond 128a90b98b move link to transport 2018-11-03 12:36:29 +01:00
Darien Raymond 9e66f315e6 update mocks 2018-10-23 22:41:27 +02:00
Darien Raymond 5fc606ce9d relocate mocks 2018-10-23 22:27:45 +02:00
Darien Raymond f78cf6cfc2 testing with mock 2018-10-22 15:58:52 +02:00
Darien Raymond 307aac26b3 simplify dependency resolution 2018-10-22 11:26:22 +02:00
Darien Raymond 9decb3fe36 comments 2018-10-22 08:42:10 +02:00
Darien Raymond a5dcb0f13e refactor dependency resolution 2018-10-21 10:27:13 +02:00
Darien Raymond abf0cb1ec4 move function to features 2018-10-13 15:15:49 +02:00
Darien Raymond 2440d276f1 comments 2018-10-13 12:09:58 +02:00
Darien Raymond d730637239 Require Type() for Feature 2018-10-12 23:57:56 +02:00