Skip to content

Commit

Permalink
Merge branch 'master' into rxsocks
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Sep 1, 2023
2 parents 7a5b836 + 374d30d commit 63c84c2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
8 changes: 7 additions & 1 deletion rxlib/src/main/java/org/rx/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.rx.net.TransportFlags;
import org.rx.net.dns.DnsClient;
import org.rx.net.dns.DnsServer;
import org.rx.net.http.AuthenticProxy;
import org.rx.net.rpc.Remoting;
import org.rx.net.rpc.RpcClientConfig;
import org.rx.net.rpc.RpcServerConfig;
Expand All @@ -31,6 +32,7 @@
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -79,6 +81,7 @@ public static class RSSConf {
public int waitIpInfoMillis = 1000;
public int ddnsSeconds;
public List<String> ddnsDomains;
public String godaddyProxy;
public String godaddyKey;

public boolean pcap2socks;
Expand Down Expand Up @@ -337,7 +340,10 @@ void ddns() {
int i = ddns.indexOf(".");
String domain = ddns.substring(i + 1), name = ddns.substring(0, i);
log.info("ddns-{}.{}: {}->{}", name, domain, currentIps, wanIp);
IPSearcher.godaddyDns(conf.getGodaddyKey(), domain, name, wanIp.getHostAddress());
AuthenticProxy p = conf.godaddyProxy != null
? new AuthenticProxy(Proxy.Type.SOCKS, Sockets.parseEndpoint(conf.godaddyProxy))
: null;
IPSearcher.godaddyDns(conf.getGodaddyKey(), domain, name, wanIp.getHostAddress(), p);
}
}, conf.ddnsSeconds * 1000L);
}
Expand Down
10 changes: 8 additions & 2 deletions rxlib/src/main/java/org/rx/core/Linq.java
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,14 @@ public T[] toArray() {
if (t == null) {
continue;
}
type = t.getClass();
break;
if (type == null) {
type = t.getClass();
continue;
}
if (type != t.getClass()) {
type = null;
break;
}
}
if (type == null) {
type = Object.class;
Expand Down
4 changes: 4 additions & 0 deletions rxlib/src/main/java/org/rx/net/http/AuthenticProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public class AuthenticProxy extends Proxy {
@Setter
private boolean directOnFail;

public AuthenticProxy(Type type, SocketAddress sa) {
this(type, sa, null, null);
}

public AuthenticProxy(Type type, SocketAddress sa, String username, String password) {
super(type, sa);
authenticator = (route, response) -> {
Expand Down
14 changes: 8 additions & 6 deletions rxlib/src/main/java/org/rx/net/support/IPSearcher.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package org.rx.net.support;

import org.rx.net.http.AuthenticProxy;
import org.rx.net.http.HttpClient;

public interface IPSearcher {
IPSearcher DEFAULT = new ComboIPSearcher();

static String godaddyDns(String ssoKey, String domain, String name) {
return godaddyDns(ssoKey, domain, name, DEFAULT.currentIp());
return godaddyDns(ssoKey, domain, name, DEFAULT.currentIp(), null);
}

static String godaddyDns(String ssoKey, String domain, String name, String ip) {
String url = String.format("https://api.godaddy.com/v1/domains/%s/records/A/%s", domain, name);
HttpClient client = new HttpClient();
client.requestHeaders().add("Authorization", "sso-key " + ssoKey);
return client.putJson(url, String.format("[\n" +
static String godaddyDns(String ssoKey, String domain, String name, String ip, AuthenticProxy proxy) {
String u = String.format("https://api.godaddy.com/v1/domains/%s/records/A/%s", domain, name);
HttpClient c = new HttpClient();
c.setProxy(proxy);
c.requestHeaders().add("Authorization", "sso-key " + ssoKey);
return c.putJson(u, String.format("[\n" +
" {\n" +
" \"data\": \"%s\",\n" +
" \"ttl\": 600\n" +
Expand Down

0 comments on commit 63c84c2

Please sign in to comment.