Commit Graph
127 Commits
Author SHA1 Message Date
loyalsoldier ab09286eec Chore: format code 2021-03-16 08:50:04 +08:00
loyalsoldier 327ad1a52a Merge branch 'master' into v5 2021-03-16 08:38:04 +08:00
Loyalsoldier e46204f828 Chore: fix lint according to golangci-lint errors (#781)
* Chore: fix lint according to golangci-lint errors
* Chore: regenerate pb.go files
2021-03-14 07:44:47 +08:00
aaa9e788e7 Grpc Gun Transport (#757)
* introduce grpc transport structure

* fix package name inconsistency

* grpc gun transport dialer and listener

* add selective build tag

* add grpc:gun listener

* add grpc:gun config

* add generated files

* various bug fix for gun:grpc transport

* Cache dialed connections

* grpc:gun Use V2Ray Managed Dial function

* Update destination.pb.go

* Update gun.go

* GunSettings -> GunConfig

* gu -> gs

* add grpc alias

Co-authored-by: RPRX <63339210+rprx@users.noreply.github.com>
Co-authored-by: kslr <kslrwang@gmail.com>
2021-03-11 16:46:17 +08:00
Jebbs 1f220e1f48 refine api, run command and merger (#766)
* mergers code optimize

* api log work with pipe

* remove inbounds/outbounds by tags
*fix rmo flag parse

* cmds description and message optimize
2021-03-11 05:03:26 +08:00
Shelikhoo 5f3851df39 Fix dependency cycle caused by core import in internet package 2021-02-28 19:10:38 +00:00
Jebbsandloyalsoldier 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
Loyalsoldier 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
Jebbs 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
秋のかえで 36ba06837f V5: Add TOML Support (#564) 2021-01-01 22:18:47 +08:00
Jebbs a5e24544a2 fix commands issues (#492)
* fix api commands output

* remove unused code

* fix convert always has -r

* update merge err to locate failed file
2020-12-20 13:35:52 +08:00
Loyalsoldier 8702812735 Chore: fix lint (#533) 2020-12-20 11:30:31 +08:00
Jebbs 7c1ab06206 v5: Remove v2ctl & wv2ray (#488)
* remove v2ctl, wv2ray
* remove v2ctl, wv2ray build scripts
* remove infra/control/main
* remove !confonly flag
* remove ctlcmd package
* remove Confgi.Override func
* move commands package into main
2020-12-04 22:32:55 +08:00
Jebbs 9367e9b1f2 V5: YAML support (#475)
* yml support

* code optimize

* remove external conf loaders

* update yaml test
code optimize

* code optimize

* fix a typo

* update convert desc
2020-12-03 06:11:24 +08:00
loyalsoldier 9475e8df3c Merge branch 'master' into v5 2020-11-30 20:59:04 +08:00
Loyalsoldier 7de5bca056 Remove Bazel (#469)
due to https://github.com/v2fly/v2ray-core/pull/468
2020-11-30 20:48:17 +08:00
kslr aa24f9a638 remove mtproto 2020-11-28 22:28:14 +08:00
Jebbs ff59bd37ce v5: New multi-json loader (#451)
* scalable commands column

* new multi-json loader
For both internal & external json loader

This commit also:
* applies -confdir to other formats, e.g. "yaml" in the future
* multiple assign of -confdir is accepted
* add flag to load confdir recursively
* config loader can have alias name
* json loader also accepts .jsonc
* add merge command
* add help topics for json merge, format loader
* format loaders don't panic

* apply lint style

* add merge test

* merge same tag in array, solve v2fly/discussion#97

* apply lint style

* merge code optimize

* fix merge cmdarg.Arg

* update cmd description

* improve merge logic
* fix zero value overwrite
* fix "null" lost after array merge

* code optimize

* fix merged slices not sorted

* code optimize

* add package doc

* fix a typo
2020-11-28 22:06:03 +08:00
Jebbs 521120d196 go style commands, merge v2ctl commands, v5 oriented (#369)
* go style commands
merge v2ctl commandsw

* migrate go style commands to v2ctl

* fixes & code optimize

* sort the commands

* update commands description

* restore old proto
golang.org proto has removed UnmarshalText, without alternative

* add test command

* remove unused code

* code optimize and fix
* The commit simplifies the run and test commands code,
* Fixes a hidden issue that the format flag not applied in command "v2ray test -format=pb ..."

* fix default loader logic
2020-11-23 23:38:43 +08:00
Loyalsoldier b68f943c78 Fix lint according to golangci-lint (#439) 2020-11-22 05:05:01 +08:00
Xiaokang Wang 61112d8af7 Workaround for muti-json's hard coded override method (#409)
* Simple workaround for muti-json unable to automatically understand new config options.

* Update jsonem.go
2020-11-21 02:50:46 +08:00
Kslrandloyalsoldier 623cb24644 Remove XTLS (#431)
* remove xtls

* generate pb

* Update protoc

* Clean up go.mod & go.sum

* format code

* restore vless flow

* fix codacy

* do NOT interfere with pb.go files

Co-authored-by: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
2020-11-20 15:53:10 +08:00
Xiaokang Wang 3684dc15de Merge pull request #351 from v2fly/dev-fix-mutijson-dep
Fix json parsing dependency introduced by mutijson config
2020-10-26 15:44:58 +00:00
Shelikhoo 9391f7c377 Apply Coding Style 2020-10-23 19:51:39 +01:00
Kslr 0dc17643a0 Merge pull request #299 from forever8938/master
Load JSON internally by default
2020-10-24 01:39:11 +08:00
Shelikhoo fd2638c522 Fix json parsing dependency introduced by mutijson config 2020-10-23 15:04:03 +01:00
kslr 3c6e11673f revert: support yaml config 2020-10-20 14:01:16 +08:00
ayanamist 5230dfb71e Support YAML config through JSON (#331) 2020-10-19 07:28:33 +08:00
loyalsoldier 784775f689 Refine code according to golangci-lint results 2020-10-11 19:22:46 +08:00
forever8938 51d3fc694f Load JSON internally by default
why not?
2020-10-10 21:06:13 +08:00
Loyalsoldier ba99e32b2d Bazel: discard GOPATH (#278) 2020-10-07 18:35:21 +08:00
loyalsoldier b181045b0c Errorgen: support to run outside of GOPATH 2020-10-04 13:06:12 +08:00
Loyalsoldier dcf368bd93 Refine Azure Pipelines & Bazel: remove unnecessary steps (#246)
* Bazel: remove GPG sign
* Azure Pipelines: remove unnecessary steps
2020-10-02 16:09:33 +08:00
e445d21f4b Add trojan protocol support (#181)
* Add trojan protocol support

Co-authored-by: Eken Chan <ekenchan@msn.com>
Co-authored-by: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
Co-authored-by: GitHub Action <action@github.com>
2020-09-26 23:31:24 +08:00
RPRX 97eddc2374 Add XTLS support 2020-09-21 14:56:43 +00:00
RPRX bad7e2cfd8 VLESS PREVIEW 1.1 2020-07-28 15:00:23 +00:00
RPRX c8f266c740 Adjust Bazel 2020-07-19 02:40:33 +00:00
rprx 4947537eee Adjust arm build 2020-06-28 08:56:55 +00:00
rprx 694180fc9a Add windows arm build (#39)
* Add windows arm build

* Add windows arm build

* Add windows arm build
2020-06-28 00:46:43 +08:00
Agioi Theodoroi 37a55653e9 remove unused parameter 2020-06-27 07:51:44 +08:00
Agioi Theodoroi 97074c5bf4 gofmt 2020-06-27 07:51:43 +08:00
kslr bc96f75bcb add armv5 2020-06-19 20:20:14 +08:00
vcptr 0fd0c374c1 fix config compatibility with old inbound/inboundDetors/out 2020-03-24 21:52:03 +08:00
vcptr 94ea326d89 fix confdir env startup priority 2020-03-24 21:52:03 +08:00
Shelikhoo e61b44ff78 Fix Test Parse flag before flag defined by V2 in main 2020-03-23 11:34:53 +08:00
vcptr 0d71d3dcf8 revert back to multiconfig 2020-03-19 19:11:16 +08:00
Kslr fdbec9a141 Revert "multiple config" 2020-01-02 01:23:56 +08:00