102-Read-listening-mode-from-config.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. --- a/src/jconf.c
  2. +++ b/src/jconf.c
  3. @@ -259,6 +259,19 @@ read_jconf(const char *file)
  4. conf.server_legacy.obfs = to_string(value);
  5. } else if (strcmp(name, "obfs_param") == 0) { // SSR
  6. conf.server_legacy.obfs_param = to_string(value);
  7. + } else if (strcmp(name, "mode") == 0) {
  8. + char *mode_str = to_string(value);
  9. +
  10. + if (strcmp(mode_str, "tcp_only") == 0)
  11. + conf.mode = TCP_ONLY;
  12. + else if (strcmp(mode_str, "tcp_and_udp") == 0)
  13. + conf.mode = TCP_AND_UDP;
  14. + else if (strcmp(mode_str, "udp_only") == 0)
  15. + conf.mode = UDP_ONLY;
  16. + else
  17. + LOGI("ignore unknown mode: %s, use tcp_only as fallback",
  18. + mode_str);
  19. + ss_free(mode_str);
  20. } else {
  21. match = 0;
  22. }
  23. --- a/src/redir.c
  24. +++ b/src/redir.c
  25. @@ -1252,6 +1252,9 @@ main(int argc, char **argv)
  26. if (user == NULL) {
  27. user = conf->user;
  28. }
  29. + if (mode == TCP_ONLY) {
  30. + mode = conf->mode;
  31. + }
  32. if (mtu == 0) {
  33. mtu = conf->mtu;
  34. }