换成单集群模式
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -24,4 +24,5 @@ require (
|
||||
golang.org/x/tools v0.40.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251029180050-ab9386a59fda // indirect
|
||||
google.golang.org/protobuf v1.36.10 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
)
|
||||
|
||||
@@ -63,5 +63,7 @@ google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
172
EdgeHttpDNS/internal/accesslogs/httpdns_file_writer.go
Normal file
172
EdgeHttpDNS/internal/accesslogs/httpdns_file_writer.go
Normal file
@@ -0,0 +1,172 @@
|
||||
package accesslogs
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultHTTPDNSLogDir = "/var/log/edge/edge-httpdns"
|
||||
envHTTPDNSLogDir = "EDGE_HTTPDNS_LOG_DIR"
|
||||
)
|
||||
|
||||
var (
|
||||
sharedHTTPDNSFileWriter *HTTPDNSFileWriter
|
||||
sharedHTTPDNSFileWriterOnce sync.Once
|
||||
)
|
||||
|
||||
// SharedHTTPDNSFileWriter 返回 HTTPDNS 本地日志写入器(单例).
|
||||
func SharedHTTPDNSFileWriter() *HTTPDNSFileWriter {
|
||||
sharedHTTPDNSFileWriterOnce.Do(func() {
|
||||
sharedHTTPDNSFileWriter = NewHTTPDNSFileWriter()
|
||||
})
|
||||
return sharedHTTPDNSFileWriter
|
||||
}
|
||||
|
||||
// HTTPDNSFileWriter 将 HTTPDNS 访问日志以 JSON Lines 写入本地文件,供 Fluent Bit 采集。
|
||||
type HTTPDNSFileWriter struct {
|
||||
dir string
|
||||
mu sync.Mutex
|
||||
file *lumberjack.Logger
|
||||
rotateConfig *serverconfigs.AccessLogRotateConfig
|
||||
inited bool
|
||||
}
|
||||
|
||||
// NewHTTPDNSFileWriter 创建 HTTPDNS 本地日志写入器.
|
||||
func NewHTTPDNSFileWriter() *HTTPDNSFileWriter {
|
||||
logDir := resolveDefaultHTTPDNSLogDir()
|
||||
return &HTTPDNSFileWriter{
|
||||
dir: logDir,
|
||||
rotateConfig: serverconfigs.NewDefaultAccessLogRotateConfig(),
|
||||
}
|
||||
}
|
||||
|
||||
func resolveDefaultHTTPDNSLogDir() string {
|
||||
logDir := strings.TrimSpace(os.Getenv(envHTTPDNSLogDir))
|
||||
if logDir == "" {
|
||||
return defaultHTTPDNSLogDir
|
||||
}
|
||||
return logDir
|
||||
}
|
||||
|
||||
// SetDir 更新日志目录并重置文件句柄。
|
||||
func (w *HTTPDNSFileWriter) SetDir(dir string) {
|
||||
if strings.TrimSpace(dir) == "" {
|
||||
dir = resolveDefaultHTTPDNSLogDir()
|
||||
}
|
||||
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
|
||||
if dir == w.dir {
|
||||
return
|
||||
}
|
||||
|
||||
if w.file != nil {
|
||||
_ = w.file.Close()
|
||||
w.file = nil
|
||||
}
|
||||
w.inited = false
|
||||
w.dir = dir
|
||||
}
|
||||
|
||||
// Dir 返回当前日志目录.
|
||||
func (w *HTTPDNSFileWriter) Dir() string {
|
||||
return w.dir
|
||||
}
|
||||
|
||||
// EnsureInit 在启动时预创建目录与 access.log.
|
||||
func (w *HTTPDNSFileWriter) EnsureInit() error {
|
||||
if w.dir == "" {
|
||||
return nil
|
||||
}
|
||||
return w.init()
|
||||
}
|
||||
|
||||
func (w *HTTPDNSFileWriter) init() error {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
|
||||
if w.inited && w.file != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if w.dir == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(w.dir, 0755); err != nil {
|
||||
log.Println("[HTTPDNS_ACCESS_LOG]mkdir log dir failed:", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
rotateConfig := w.rotateConfig.Normalize()
|
||||
w.file = &lumberjack.Logger{
|
||||
Filename: filepath.Join(w.dir, "access.log"),
|
||||
MaxSize: rotateConfig.MaxSizeMB,
|
||||
MaxBackups: rotateConfig.MaxBackups,
|
||||
MaxAge: rotateConfig.MaxAgeDays,
|
||||
Compress: *rotateConfig.Compress,
|
||||
LocalTime: *rotateConfig.LocalTime,
|
||||
}
|
||||
|
||||
w.inited = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteBatch 批量写入 HTTPDNS 访问日志.
|
||||
func (w *HTTPDNSFileWriter) WriteBatch(logs []*pb.HTTPDNSAccessLog) {
|
||||
if len(logs) == 0 || w.dir == "" {
|
||||
return
|
||||
}
|
||||
if err := w.init(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
w.mu.Lock()
|
||||
file := w.file
|
||||
w.mu.Unlock()
|
||||
if file == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, logItem := range logs {
|
||||
ingestLog := FromPBAccessLog(logItem)
|
||||
if ingestLog == nil {
|
||||
continue
|
||||
}
|
||||
line, err := json.Marshal(ingestLog)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
_, _ = file.Write(append(line, '\n'))
|
||||
}
|
||||
}
|
||||
|
||||
// Close 关闭日志文件.
|
||||
func (w *HTTPDNSFileWriter) Close() error {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
|
||||
if w.file == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := w.file.Close()
|
||||
w.file = nil
|
||||
w.inited = false
|
||||
if err != nil {
|
||||
log.Println(fmt.Sprintf("[HTTPDNS_ACCESS_LOG]close access.log failed: %v", err))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
57
EdgeHttpDNS/internal/accesslogs/httpdns_ingest_log.go
Normal file
57
EdgeHttpDNS/internal/accesslogs/httpdns_ingest_log.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package accesslogs
|
||||
|
||||
import "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
|
||||
// HTTPDNSIngestLog HTTPDNS 访问日志单行结构(JSONEachRow),字段与
|
||||
// ClickHouse httpdns_access_logs_ingest 表一一对应。
|
||||
type HTTPDNSIngestLog struct {
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
RequestId string `json:"request_id"`
|
||||
ClusterId int64 `json:"cluster_id"`
|
||||
NodeId int64 `json:"node_id"`
|
||||
AppId string `json:"app_id"`
|
||||
AppName string `json:"app_name"`
|
||||
Domain string `json:"domain"`
|
||||
QType string `json:"qtype"`
|
||||
ClientIP string `json:"client_ip"`
|
||||
ClientRegion string `json:"client_region"`
|
||||
Carrier string `json:"carrier"`
|
||||
SDKVersion string `json:"sdk_version"`
|
||||
OS string `json:"os"`
|
||||
ResultIPs string `json:"result_ips"`
|
||||
Status string `json:"status"`
|
||||
ErrorCode string `json:"error_code"`
|
||||
CostMs int32 `json:"cost_ms"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
Day string `json:"day"`
|
||||
Summary string `json:"summary"`
|
||||
}
|
||||
|
||||
// FromPBAccessLog 将 pb.HTTPDNSAccessLog 转为本地 ingest 结构。
|
||||
func FromPBAccessLog(log *pb.HTTPDNSAccessLog) *HTTPDNSIngestLog {
|
||||
if log == nil {
|
||||
return nil
|
||||
}
|
||||
return &HTTPDNSIngestLog{
|
||||
Timestamp: log.GetCreatedAt(),
|
||||
RequestId: log.GetRequestId(),
|
||||
ClusterId: log.GetClusterId(),
|
||||
NodeId: log.GetNodeId(),
|
||||
AppId: log.GetAppId(),
|
||||
AppName: log.GetAppName(),
|
||||
Domain: log.GetDomain(),
|
||||
QType: log.GetQtype(),
|
||||
ClientIP: log.GetClientIP(),
|
||||
ClientRegion: log.GetClientRegion(),
|
||||
Carrier: log.GetCarrier(),
|
||||
SDKVersion: log.GetSdkVersion(),
|
||||
OS: log.GetOs(),
|
||||
ResultIPs: log.GetResultIPs(),
|
||||
Status: log.GetStatus(),
|
||||
ErrorCode: log.GetErrorCode(),
|
||||
CostMs: log.GetCostMs(),
|
||||
CreatedAt: log.GetCreatedAt(),
|
||||
Day: log.GetDay(),
|
||||
Summary: log.GetSummary(),
|
||||
}
|
||||
}
|
||||
@@ -13,14 +13,18 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/iplibrary"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
|
||||
"github.com/TeaOSLab/EdgeHttpDNS/internal/accesslogs"
|
||||
"github.com/TeaOSLab/EdgeHttpDNS/internal/configs"
|
||||
"github.com/TeaOSLab/EdgeHttpDNS/internal/rpc"
|
||||
"github.com/iwind/TeaGo/rands"
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
@@ -83,61 +87,79 @@ type clientRouteProfile struct {
|
||||
RegionText string
|
||||
}
|
||||
|
||||
type ResolveServer struct {
|
||||
quitCh <-chan struct{}
|
||||
type tlsListener struct {
|
||||
addr string // e.g. ":443"
|
||||
listener net.Listener
|
||||
server *http.Server
|
||||
}
|
||||
|
||||
type ResolveServer struct {
|
||||
quitCh <-chan struct{}
|
||||
snapshotManager *SnapshotManager
|
||||
|
||||
listenAddr string
|
||||
certFile string
|
||||
keyFile string
|
||||
server *http.Server
|
||||
// Local config fallback
|
||||
fallbackAddr string
|
||||
certFile string
|
||||
keyFile string
|
||||
|
||||
logQueue chan *pb.HTTPDNSAccessLog
|
||||
handler http.Handler // shared mux
|
||||
tlsConfig *tls.Config // shared TLS config (with GetCertificate)
|
||||
|
||||
logWriter *accesslogs.HTTPDNSFileWriter
|
||||
logQueue chan *pb.HTTPDNSAccessLog
|
||||
|
||||
// TLS certificate hot-reload
|
||||
certMu sync.RWMutex
|
||||
currentCert *tls.Certificate
|
||||
certSnapshotAt int64
|
||||
|
||||
// Listener hot-reload
|
||||
listenerMu sync.Mutex
|
||||
listeners map[string]*tlsListener // key: addr (e.g. ":443")
|
||||
}
|
||||
|
||||
func NewResolveServer(quitCh <-chan struct{}, snapshotManager *SnapshotManager) *ResolveServer {
|
||||
listenAddr := ":443"
|
||||
fallbackAddr := ":443"
|
||||
certFile := ""
|
||||
keyFile := ""
|
||||
if apiConfig, err := configs.SharedAPIConfig(); err == nil && apiConfig != nil {
|
||||
if len(apiConfig.HTTPSListenAddr) > 0 {
|
||||
listenAddr = apiConfig.HTTPSListenAddr
|
||||
fallbackAddr = apiConfig.HTTPSListenAddr
|
||||
}
|
||||
certFile = apiConfig.HTTPSCert
|
||||
keyFile = apiConfig.HTTPSKey
|
||||
}
|
||||
|
||||
logWriter := accesslogs.SharedHTTPDNSFileWriter()
|
||||
if apiConfig, err := configs.SharedAPIConfig(); err == nil && apiConfig != nil {
|
||||
if len(strings.TrimSpace(apiConfig.LogDir)) > 0 {
|
||||
logWriter.SetDir(strings.TrimSpace(apiConfig.LogDir))
|
||||
}
|
||||
}
|
||||
if err := logWriter.EnsureInit(); err != nil {
|
||||
log.Println("[HTTPDNS_NODE][resolve]init access log file writer failed:", err.Error())
|
||||
}
|
||||
|
||||
instance := &ResolveServer{
|
||||
quitCh: quitCh,
|
||||
snapshotManager: snapshotManager,
|
||||
listenAddr: listenAddr,
|
||||
fallbackAddr: fallbackAddr,
|
||||
certFile: certFile,
|
||||
keyFile: keyFile,
|
||||
logWriter: logWriter,
|
||||
logQueue: make(chan *pb.HTTPDNSAccessLog, 8192),
|
||||
listeners: make(map[string]*tlsListener),
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/resolve", instance.handleResolve)
|
||||
mux.HandleFunc("/healthz", instance.handleHealth)
|
||||
instance.handler = mux
|
||||
|
||||
instance.server = &http.Server{
|
||||
Addr: instance.listenAddr,
|
||||
Handler: mux,
|
||||
ReadTimeout: 5 * time.Second,
|
||||
ReadHeaderTimeout: 3 * time.Second,
|
||||
WriteTimeout: 5 * time.Second,
|
||||
IdleTimeout: 75 * time.Second,
|
||||
MaxHeaderBytes: 8 * 1024,
|
||||
TLSConfig: &tls.Config{
|
||||
MinVersion: tls.VersionTLS11,
|
||||
// /resolve is a small JSON API; pin to HTTP/1.1 to avoid ALPN/h2 handshake variance
|
||||
// across some clients and middleboxes.
|
||||
NextProtos: []string{"http/1.1"},
|
||||
},
|
||||
// Disable automatic HTTP/2 upgrade on TLS listeners. This keeps handshake behavior
|
||||
// deterministic for SDK resolve calls.
|
||||
TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){},
|
||||
instance.tlsConfig = &tls.Config{
|
||||
MinVersion: tls.VersionTLS11,
|
||||
NextProtos: []string{"http/1.1"},
|
||||
GetCertificate: instance.getCertificate,
|
||||
}
|
||||
|
||||
return instance
|
||||
@@ -145,19 +167,240 @@ func NewResolveServer(quitCh <-chan struct{}, snapshotManager *SnapshotManager)
|
||||
|
||||
func (s *ResolveServer) Start() {
|
||||
go s.startAccessLogFlusher()
|
||||
go s.waitForShutdown()
|
||||
|
||||
log.Println("[HTTPDNS_NODE][resolve]listening HTTPS on", s.listenAddr)
|
||||
if err := s.server.ListenAndServeTLS(s.certFile, s.keyFile); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Println("[HTTPDNS_NODE][resolve]listen failed:", err.Error())
|
||||
// 1. Load initial certificate from file (fallback)
|
||||
if len(s.certFile) > 0 && len(s.keyFile) > 0 {
|
||||
cert, err := tls.LoadX509KeyPair(s.certFile, s.keyFile)
|
||||
if err != nil {
|
||||
log.Println("[HTTPDNS_NODE][resolve]load cert file failed:", err.Error())
|
||||
} else {
|
||||
s.currentCert = &cert
|
||||
log.Println("[HTTPDNS_NODE][resolve]loaded initial TLS cert from file")
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Try loading certificate from cluster snapshot (takes priority over file)
|
||||
if snapshot := s.snapshotManager.Current(); snapshot != nil {
|
||||
s.reloadCertFromSnapshot(snapshot)
|
||||
}
|
||||
|
||||
if s.currentCert == nil {
|
||||
log.Println("[HTTPDNS_NODE][resolve]WARNING: no TLS certificate available, HTTPS will fail")
|
||||
}
|
||||
|
||||
// 3. Parse initial listen addresses and start listeners
|
||||
if snapshot := s.snapshotManager.Current(); snapshot != nil {
|
||||
addrs := s.desiredAddrs(snapshot)
|
||||
s.syncListeners(addrs)
|
||||
} else {
|
||||
s.syncListeners([]string{s.fallbackAddr})
|
||||
}
|
||||
|
||||
// 4. Watch for changes (blocks until quit)
|
||||
s.watchLoop()
|
||||
}
|
||||
|
||||
func (s *ResolveServer) getCertificate(_ *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
||||
s.certMu.RLock()
|
||||
cert := s.currentCert
|
||||
s.certMu.RUnlock()
|
||||
if cert != nil {
|
||||
return cert, nil
|
||||
}
|
||||
return nil, errors.New("no TLS certificate available")
|
||||
}
|
||||
|
||||
type snapshotTLSConfig struct {
|
||||
Listen []*serverconfigs.NetworkAddressConfig `json:"listen"`
|
||||
SSLPolicy *sslconfigs.SSLPolicy `json:"sslPolicy"`
|
||||
}
|
||||
|
||||
func (s *ResolveServer) parseTLSConfig(snapshot *LoadedSnapshot) *snapshotTLSConfig {
|
||||
if snapshot.ClusterID <= 0 {
|
||||
return nil
|
||||
}
|
||||
cluster := snapshot.Clusters[snapshot.ClusterID]
|
||||
if cluster == nil {
|
||||
return nil
|
||||
}
|
||||
raw := cluster.GetTlsPolicyJSON()
|
||||
if len(raw) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var cfg snapshotTLSConfig
|
||||
if err := json.Unmarshal(raw, &cfg); err != nil {
|
||||
log.Println("[HTTPDNS_NODE][resolve]parse tlsPolicyJSON failed:", err.Error())
|
||||
return nil
|
||||
}
|
||||
return &cfg
|
||||
}
|
||||
|
||||
func (s *ResolveServer) desiredAddrs(snapshot *LoadedSnapshot) []string {
|
||||
cfg := s.parseTLSConfig(snapshot)
|
||||
if cfg == nil || len(cfg.Listen) == 0 {
|
||||
return []string{s.fallbackAddr}
|
||||
}
|
||||
|
||||
seen := make(map[string]struct{})
|
||||
var addrs []string
|
||||
for _, listenCfg := range cfg.Listen {
|
||||
if listenCfg == nil {
|
||||
continue
|
||||
}
|
||||
if err := listenCfg.Init(); err != nil {
|
||||
log.Println("[HTTPDNS_NODE][resolve]init listen config failed:", err.Error())
|
||||
continue
|
||||
}
|
||||
for _, addr := range listenCfg.Addresses() {
|
||||
if _, ok := seen[addr]; !ok {
|
||||
seen[addr] = struct{}{}
|
||||
addrs = append(addrs, addr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(addrs) == 0 {
|
||||
return []string{s.fallbackAddr}
|
||||
}
|
||||
sort.Strings(addrs)
|
||||
return addrs
|
||||
}
|
||||
|
||||
func (s *ResolveServer) reloadCertFromSnapshot(snapshot *LoadedSnapshot) {
|
||||
cfg := s.parseTLSConfig(snapshot)
|
||||
if cfg == nil || cfg.SSLPolicy == nil || len(cfg.SSLPolicy.Certs) == 0 {
|
||||
s.certMu.Lock()
|
||||
s.certSnapshotAt = snapshot.LoadedAt
|
||||
s.certMu.Unlock()
|
||||
return
|
||||
}
|
||||
if err := cfg.SSLPolicy.Init(context.Background()); err != nil {
|
||||
log.Println("[HTTPDNS_NODE][resolve]init SSLPolicy failed:", err.Error())
|
||||
s.certMu.Lock()
|
||||
s.certSnapshotAt = snapshot.LoadedAt
|
||||
s.certMu.Unlock()
|
||||
return
|
||||
}
|
||||
cert := cfg.SSLPolicy.FirstCert()
|
||||
if cert == nil {
|
||||
s.certMu.Lock()
|
||||
s.certSnapshotAt = snapshot.LoadedAt
|
||||
s.certMu.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
s.certMu.Lock()
|
||||
s.currentCert = cert
|
||||
s.certSnapshotAt = snapshot.LoadedAt
|
||||
s.certMu.Unlock()
|
||||
log.Println("[HTTPDNS_NODE][resolve]TLS certificate reloaded from snapshot")
|
||||
}
|
||||
|
||||
func (s *ResolveServer) startListener(addr string) error {
|
||||
ln, err := net.Listen("tcp", addr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("listen on %s: %w", addr, err)
|
||||
}
|
||||
tlsLn := tls.NewListener(ln, s.tlsConfig)
|
||||
|
||||
srv := &http.Server{
|
||||
Handler: s.handler,
|
||||
ReadTimeout: 5 * time.Second,
|
||||
ReadHeaderTimeout: 3 * time.Second,
|
||||
WriteTimeout: 5 * time.Second,
|
||||
IdleTimeout: 75 * time.Second,
|
||||
MaxHeaderBytes: 8 * 1024,
|
||||
TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){},
|
||||
}
|
||||
|
||||
s.listeners[addr] = &tlsListener{
|
||||
addr: addr,
|
||||
listener: tlsLn,
|
||||
server: srv,
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := srv.Serve(tlsLn); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Println("[HTTPDNS_NODE][resolve]serve failed on", addr, ":", err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
log.Println("[HTTPDNS_NODE][resolve]listening HTTPS on", addr)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ResolveServer) stopListener(addr string) {
|
||||
tl, ok := s.listeners[addr]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
_ = tl.server.Shutdown(ctx)
|
||||
delete(s.listeners, addr)
|
||||
log.Println("[HTTPDNS_NODE][resolve]stopped listener on", addr)
|
||||
}
|
||||
|
||||
func (s *ResolveServer) syncListeners(desired []string) {
|
||||
s.listenerMu.Lock()
|
||||
defer s.listenerMu.Unlock()
|
||||
|
||||
desiredSet := make(map[string]struct{}, len(desired))
|
||||
for _, addr := range desired {
|
||||
desiredSet[addr] = struct{}{}
|
||||
}
|
||||
|
||||
// Stop listeners that are no longer desired
|
||||
for addr := range s.listeners {
|
||||
if _, ok := desiredSet[addr]; !ok {
|
||||
s.stopListener(addr)
|
||||
}
|
||||
}
|
||||
|
||||
// Start new listeners
|
||||
for _, addr := range desired {
|
||||
if _, ok := s.listeners[addr]; !ok {
|
||||
if err := s.startListener(addr); err != nil {
|
||||
log.Println("[HTTPDNS_NODE][resolve]start listener failed:", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ResolveServer) waitForShutdown() {
|
||||
<-s.quitCh
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
_ = s.server.Shutdown(ctx)
|
||||
func (s *ResolveServer) watchLoop() {
|
||||
ticker := time.NewTicker(5 * time.Second)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
snapshot := s.snapshotManager.Current()
|
||||
if snapshot == nil {
|
||||
continue
|
||||
}
|
||||
s.certMu.RLock()
|
||||
lastAt := s.certSnapshotAt
|
||||
s.certMu.RUnlock()
|
||||
if snapshot.LoadedAt == lastAt {
|
||||
continue
|
||||
}
|
||||
// Snapshot changed — sync listeners and reload cert
|
||||
addrs := s.desiredAddrs(snapshot)
|
||||
s.syncListeners(addrs)
|
||||
s.reloadCertFromSnapshot(snapshot)
|
||||
case <-s.quitCh:
|
||||
s.shutdownAll()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ResolveServer) shutdownAll() {
|
||||
s.listenerMu.Lock()
|
||||
defer s.listenerMu.Unlock()
|
||||
for addr := range s.listeners {
|
||||
s.stopListener(addr)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ResolveServer) handleHealth(writer http.ResponseWriter, _ *http.Request) {
|
||||
@@ -219,11 +462,22 @@ func (s *ResolveServer) handleResolve(writer http.ResponseWriter, request *http.
|
||||
return
|
||||
}
|
||||
|
||||
if snapshot.ClusterID > 0 &&
|
||||
loadedApp.App.GetPrimaryClusterId() != snapshot.ClusterID &&
|
||||
loadedApp.App.GetBackupClusterId() != snapshot.ClusterID {
|
||||
s.writeFailedResolve(writer, requestID, snapshot, loadedApp.App, domain, qtype, httpdnsCodeAppInvalid, "当前应用未绑定到该解析集群", startAt, request, query)
|
||||
return
|
||||
if snapshot.ClusterID > 0 {
|
||||
var appClusterIds []int64
|
||||
if len(loadedApp.App.GetClusterIdsJSON()) > 0 {
|
||||
_ = json.Unmarshal(loadedApp.App.GetClusterIdsJSON(), &appClusterIds)
|
||||
}
|
||||
var clusterBound bool
|
||||
for _, cid := range appClusterIds {
|
||||
if cid == snapshot.ClusterID {
|
||||
clusterBound = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !clusterBound {
|
||||
s.writeFailedResolve(writer, requestID, snapshot, loadedApp.App, domain, qtype, httpdnsCodeAppInvalid, "当前应用未绑定到该解析集群", startAt, request, query)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
loadedDomain := loadedApp.Domains[domain]
|
||||
@@ -341,11 +595,14 @@ func pickDefaultTTL(snapshot *LoadedSnapshot, app *pb.HTTPDNSApp) int32 {
|
||||
}
|
||||
}
|
||||
if app != nil {
|
||||
if cluster := snapshot.Clusters[app.GetPrimaryClusterId()]; cluster != nil && cluster.GetDefaultTTL() > 0 {
|
||||
return cluster.GetDefaultTTL()
|
||||
var appClusterIds []int64
|
||||
if len(app.GetClusterIdsJSON()) > 0 {
|
||||
_ = json.Unmarshal(app.GetClusterIdsJSON(), &appClusterIds)
|
||||
}
|
||||
if cluster := snapshot.Clusters[app.GetBackupClusterId()]; cluster != nil && cluster.GetDefaultTTL() > 0 {
|
||||
return cluster.GetDefaultTTL()
|
||||
for _, cid := range appClusterIds {
|
||||
if cluster := snapshot.Clusters[cid]; cluster != nil && cluster.GetDefaultTTL() > 0 {
|
||||
return cluster.GetDefaultTTL()
|
||||
}
|
||||
}
|
||||
}
|
||||
return 30
|
||||
@@ -591,15 +848,19 @@ func normalizeChinaRegion(province string) string {
|
||||
|
||||
func normalizeContinent(country string) string {
|
||||
switch normalizeCountryName(country) {
|
||||
case "中国", "中国香港", "中国澳门", "中国台湾", "日本", "韩国", "新加坡", "印度", "泰国", "越南":
|
||||
case "中国", "中国香港", "中国澳门", "中国台湾", "日本", "韩国", "新加坡", "印度", "泰国", "越南",
|
||||
"印度尼西亚", "马来西亚", "菲律宾", "柬埔寨", "缅甸", "老挝", "斯里兰卡", "孟加拉国", "巴基斯坦", "尼泊尔",
|
||||
"阿联酋", "沙特阿拉伯", "土耳其", "以色列", "伊朗", "伊拉克", "卡塔尔", "科威特", "蒙古":
|
||||
return "亚洲"
|
||||
case "美国", "加拿大", "墨西哥":
|
||||
case "美国", "加拿大", "墨西哥", "巴拿马", "哥斯达黎加", "古巴":
|
||||
return "北美洲"
|
||||
case "巴西", "阿根廷", "智利", "哥伦比亚":
|
||||
case "巴西", "阿根廷", "智利", "哥伦比亚", "秘鲁", "委内瑞拉", "厄瓜多尔":
|
||||
return "南美洲"
|
||||
case "德国", "英国", "法国", "荷兰", "西班牙", "意大利", "俄罗斯":
|
||||
case "德国", "英国", "法国", "荷兰", "西班牙", "意大利", "俄罗斯",
|
||||
"波兰", "瑞典", "瑞士", "挪威", "芬兰", "丹麦", "葡萄牙", "爱尔兰", "比利时", "奥地利",
|
||||
"乌克兰", "捷克", "罗马尼亚", "匈牙利", "希腊":
|
||||
return "欧洲"
|
||||
case "南非", "埃及", "尼日利亚", "肯尼亚", "摩洛哥":
|
||||
case "南非", "埃及", "尼日利亚", "肯尼亚", "摩洛哥", "阿尔及利亚", "坦桑尼亚", "埃塞俄比亚", "加纳", "突尼斯":
|
||||
return "非洲"
|
||||
case "澳大利亚", "新西兰":
|
||||
return "大洋洲"
|
||||
@@ -639,8 +900,8 @@ func pickRuleRecords(rules []*pb.HTTPDNSCustomRule, qtype string, profile *clien
|
||||
Type: qtype,
|
||||
IP: value,
|
||||
Weight: item.GetWeight(),
|
||||
Line: ruleLineSummary(rule),
|
||||
Region: ruleRegionSummary(rule),
|
||||
Line: lookupIPLineLabel(value),
|
||||
Region: lookupIPRegionSummary(value),
|
||||
})
|
||||
}
|
||||
if len(records) == 0 {
|
||||
@@ -969,6 +1230,91 @@ func normalizeCountryName(country string) string {
|
||||
return "智利"
|
||||
case "哥伦比亚", "colombia":
|
||||
return "哥伦比亚"
|
||||
// --- 亚洲(新增)---
|
||||
case "印度尼西亚", "indonesia":
|
||||
return "印度尼西亚"
|
||||
case "马来西亚", "malaysia":
|
||||
return "马来西亚"
|
||||
case "菲律宾", "philippines":
|
||||
return "菲律宾"
|
||||
case "柬埔寨", "cambodia":
|
||||
return "柬埔寨"
|
||||
case "缅甸", "myanmar", "burma":
|
||||
return "缅甸"
|
||||
case "老挝", "laos":
|
||||
return "老挝"
|
||||
case "斯里兰卡", "srilanka":
|
||||
return "斯里兰卡"
|
||||
case "孟加拉国", "孟加拉", "bangladesh":
|
||||
return "孟加拉国"
|
||||
case "巴基斯坦", "pakistan":
|
||||
return "巴基斯坦"
|
||||
case "尼泊尔", "nepal":
|
||||
return "尼泊尔"
|
||||
case "阿联酋", "阿拉伯联合酋长国", "uae", "unitedarabemirates":
|
||||
return "阿联酋"
|
||||
case "沙特阿拉伯", "沙特", "saudiarabia", "saudi":
|
||||
return "沙特阿拉伯"
|
||||
case "土耳其", "turkey", "türkiye", "turkiye":
|
||||
return "土耳其"
|
||||
case "以色列", "israel":
|
||||
return "以色列"
|
||||
case "伊朗", "iran":
|
||||
return "伊朗"
|
||||
case "伊拉克", "iraq":
|
||||
return "伊拉克"
|
||||
case "卡塔尔", "qatar":
|
||||
return "卡塔尔"
|
||||
case "科威特", "kuwait":
|
||||
return "科威特"
|
||||
case "蒙古", "mongolia":
|
||||
return "蒙古"
|
||||
// --- 欧洲(新增)---
|
||||
case "波兰", "poland":
|
||||
return "波兰"
|
||||
case "瑞典", "sweden":
|
||||
return "瑞典"
|
||||
case "瑞士", "switzerland":
|
||||
return "瑞士"
|
||||
case "挪威", "norway":
|
||||
return "挪威"
|
||||
case "芬兰", "finland":
|
||||
return "芬兰"
|
||||
case "丹麦", "denmark":
|
||||
return "丹麦"
|
||||
case "葡萄牙", "portugal":
|
||||
return "葡萄牙"
|
||||
case "爱尔兰", "ireland":
|
||||
return "爱尔兰"
|
||||
case "比利时", "belgium":
|
||||
return "比利时"
|
||||
case "奥地利", "austria":
|
||||
return "奥地利"
|
||||
case "乌克兰", "ukraine":
|
||||
return "乌克兰"
|
||||
case "捷克", "czech", "czechrepublic", "czechia":
|
||||
return "捷克"
|
||||
case "罗马尼亚", "romania":
|
||||
return "罗马尼亚"
|
||||
case "匈牙利", "hungary":
|
||||
return "匈牙利"
|
||||
case "希腊", "greece":
|
||||
return "希腊"
|
||||
// --- 北美洲(新增)---
|
||||
case "巴拿马", "panama":
|
||||
return "巴拿马"
|
||||
case "哥斯达黎加", "costarica":
|
||||
return "哥斯达黎加"
|
||||
case "古巴", "cuba":
|
||||
return "古巴"
|
||||
// --- 南美洲(新增)---
|
||||
case "秘鲁", "peru":
|
||||
return "秘鲁"
|
||||
case "委内瑞拉", "venezuela":
|
||||
return "委内瑞拉"
|
||||
case "厄瓜多尔", "ecuador":
|
||||
return "厄瓜多尔"
|
||||
// --- 非洲 ---
|
||||
case "南非", "southafrica":
|
||||
return "南非"
|
||||
case "埃及", "egypt":
|
||||
@@ -979,6 +1325,17 @@ func normalizeCountryName(country string) string {
|
||||
return "肯尼亚"
|
||||
case "摩洛哥", "morocco":
|
||||
return "摩洛哥"
|
||||
case "阿尔及利亚", "algeria":
|
||||
return "阿尔及利亚"
|
||||
case "坦桑尼亚", "tanzania":
|
||||
return "坦桑尼亚"
|
||||
case "埃塞俄比亚", "ethiopia":
|
||||
return "埃塞俄比亚"
|
||||
case "加纳", "ghana":
|
||||
return "加纳"
|
||||
case "突尼斯", "tunisia":
|
||||
return "突尼斯"
|
||||
// --- 大洋洲 ---
|
||||
case "澳大利亚", "australia":
|
||||
return "澳大利亚"
|
||||
case "新西兰", "newzealand":
|
||||
@@ -1087,18 +1444,7 @@ func (s *ResolveServer) startAccessLogFlusher() {
|
||||
if len(batch) == 0 {
|
||||
return
|
||||
}
|
||||
rpcClient, err := rpc.SharedRPC()
|
||||
if err != nil {
|
||||
log.Println("[HTTPDNS_NODE][resolve]access-log rpc unavailable:", err.Error())
|
||||
return
|
||||
}
|
||||
_, err = rpcClient.HTTPDNSAccessLogRPC.CreateHTTPDNSAccessLogs(rpcClient.Context(), &pb.CreateHTTPDNSAccessLogsRequest{
|
||||
Logs: batch,
|
||||
})
|
||||
if err != nil {
|
||||
log.Println("[HTTPDNS_NODE][resolve]flush access logs failed:", err.Error())
|
||||
return
|
||||
}
|
||||
s.logWriter.WriteBatch(batch)
|
||||
batch = batch[:0]
|
||||
}
|
||||
|
||||
@@ -1119,6 +1465,7 @@ func (s *ResolveServer) startAccessLogFlusher() {
|
||||
flush()
|
||||
case <-s.quitCh:
|
||||
flush()
|
||||
_ = s.logWriter.Close()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
160
EdgeHttpDNS/internal/utils/exec/cmd.go
Normal file
160
EdgeHttpDNS/internal/utils/exec/cmd.go
Normal file
@@ -0,0 +1,160 @@
|
||||
package executils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Cmd struct {
|
||||
name string
|
||||
args []string
|
||||
env []string
|
||||
dir string
|
||||
|
||||
ctx context.Context
|
||||
timeout time.Duration
|
||||
cancelFunc func()
|
||||
|
||||
captureStdout bool
|
||||
captureStderr bool
|
||||
|
||||
stdout *bytes.Buffer
|
||||
stderr *bytes.Buffer
|
||||
|
||||
rawCmd *exec.Cmd
|
||||
}
|
||||
|
||||
func NewCmd(name string, args ...string) *Cmd {
|
||||
return &Cmd{
|
||||
name: name,
|
||||
args: args,
|
||||
}
|
||||
}
|
||||
|
||||
func NewTimeoutCmd(timeout time.Duration, name string, args ...string) *Cmd {
|
||||
return (&Cmd{
|
||||
name: name,
|
||||
args: args,
|
||||
}).WithTimeout(timeout)
|
||||
}
|
||||
|
||||
func (this *Cmd) WithTimeout(timeout time.Duration) *Cmd {
|
||||
this.timeout = timeout
|
||||
|
||||
ctx, cancelFunc := context.WithTimeout(context.Background(), timeout)
|
||||
this.ctx = ctx
|
||||
this.cancelFunc = cancelFunc
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *Cmd) WithStdout() *Cmd {
|
||||
this.captureStdout = true
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *Cmd) WithStderr() *Cmd {
|
||||
this.captureStderr = true
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *Cmd) WithEnv(env []string) *Cmd {
|
||||
this.env = env
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *Cmd) WithDir(dir string) *Cmd {
|
||||
this.dir = dir
|
||||
return this
|
||||
}
|
||||
|
||||
func (this *Cmd) Start() error {
|
||||
var cmd = this.compose()
|
||||
return cmd.Start()
|
||||
}
|
||||
|
||||
func (this *Cmd) Wait() error {
|
||||
var cmd = this.compose()
|
||||
return cmd.Wait()
|
||||
}
|
||||
|
||||
func (this *Cmd) Run() error {
|
||||
if this.cancelFunc != nil {
|
||||
defer this.cancelFunc()
|
||||
}
|
||||
|
||||
var cmd = this.compose()
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func (this *Cmd) RawStdout() string {
|
||||
if this.stdout != nil {
|
||||
return this.stdout.String()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (this *Cmd) Stdout() string {
|
||||
return strings.TrimSpace(this.RawStdout())
|
||||
}
|
||||
|
||||
func (this *Cmd) RawStderr() string {
|
||||
if this.stderr != nil {
|
||||
return this.stderr.String()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (this *Cmd) Stderr() string {
|
||||
return strings.TrimSpace(this.RawStderr())
|
||||
}
|
||||
|
||||
func (this *Cmd) String() string {
|
||||
if this.rawCmd != nil {
|
||||
return this.rawCmd.String()
|
||||
}
|
||||
var newCmd = exec.Command(this.name, this.args...)
|
||||
return newCmd.String()
|
||||
}
|
||||
|
||||
func (this *Cmd) Process() *os.Process {
|
||||
if this.rawCmd != nil {
|
||||
return this.rawCmd.Process
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *Cmd) compose() *exec.Cmd {
|
||||
if this.rawCmd != nil {
|
||||
return this.rawCmd
|
||||
}
|
||||
|
||||
if this.ctx != nil {
|
||||
this.rawCmd = exec.CommandContext(this.ctx, this.name, this.args...)
|
||||
} else {
|
||||
this.rawCmd = exec.Command(this.name, this.args...)
|
||||
}
|
||||
|
||||
if this.env != nil {
|
||||
this.rawCmd.Env = this.env
|
||||
}
|
||||
|
||||
if len(this.dir) > 0 {
|
||||
this.rawCmd.Dir = this.dir
|
||||
}
|
||||
|
||||
if this.captureStdout {
|
||||
this.stdout = &bytes.Buffer{}
|
||||
this.rawCmd.Stdout = this.stdout
|
||||
}
|
||||
if this.captureStderr {
|
||||
this.stderr = &bytes.Buffer{}
|
||||
this.rawCmd.Stderr = this.stderr
|
||||
}
|
||||
|
||||
return this.rawCmd
|
||||
}
|
||||
57
EdgeHttpDNS/internal/utils/exec/look_linux.go
Normal file
57
EdgeHttpDNS/internal/utils/exec/look_linux.go
Normal file
@@ -0,0 +1,57 @@
|
||||
//go:build linux
|
||||
|
||||
package executils
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// LookPath customize our LookPath() function, to work in broken $PATH environment variable
|
||||
func LookPath(file string) (string, error) {
|
||||
result, err := exec.LookPath(file)
|
||||
if err == nil && len(result) > 0 {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// add common dirs contains executable files these may be excluded in $PATH environment variable
|
||||
var binPaths = []string{
|
||||
"/usr/sbin",
|
||||
"/usr/bin",
|
||||
"/usr/local/sbin",
|
||||
"/usr/local/bin",
|
||||
}
|
||||
|
||||
for _, binPath := range binPaths {
|
||||
var fullPath = binPath + string(os.PathSeparator) + file
|
||||
|
||||
stat, err := os.Stat(fullPath)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if stat.IsDir() {
|
||||
return "", syscall.EISDIR
|
||||
}
|
||||
|
||||
var mode = stat.Mode()
|
||||
if mode.IsDir() {
|
||||
return "", syscall.EISDIR
|
||||
}
|
||||
err = syscall.Faccessat(unix.AT_FDCWD, fullPath, unix.X_OK, unix.AT_EACCESS)
|
||||
if err == nil || (err != syscall.ENOSYS && err != syscall.EPERM) {
|
||||
return fullPath, err
|
||||
}
|
||||
if mode&0111 != 0 {
|
||||
return fullPath, nil
|
||||
}
|
||||
return "", fs.ErrPermission
|
||||
}
|
||||
|
||||
return "", &exec.Error{
|
||||
Name: file,
|
||||
Err: exec.ErrNotFound,
|
||||
}
|
||||
}
|
||||
9
EdgeHttpDNS/internal/utils/exec/look_others.go
Normal file
9
EdgeHttpDNS/internal/utils/exec/look_others.go
Normal file
@@ -0,0 +1,9 @@
|
||||
//go:build !linux
|
||||
|
||||
package executils
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func LookPath(file string) (string, error) {
|
||||
return exec.LookPath(file)
|
||||
}
|
||||
@@ -6,25 +6,107 @@ package utils
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
teaconst "github.com/TeaOSLab/EdgeHttpDNS/internal/const"
|
||||
executils "github.com/TeaOSLab/EdgeHttpDNS/internal/utils/exec"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
)
|
||||
|
||||
var systemdServiceFile = "/etc/systemd/system/" + teaconst.SystemdServiceName + ".service"
|
||||
var initServiceFile = "/etc/init.d/" + teaconst.SystemdServiceName
|
||||
|
||||
// Install 安装系统服务
|
||||
func (m *ServiceManager) Install(exePath string, args []string) error {
|
||||
if os.Getgid() != 0 {
|
||||
return errors.New("only root users can install the service")
|
||||
}
|
||||
|
||||
systemd, err := exec.LookPath("systemctl")
|
||||
systemd, err := executils.LookPath("systemctl")
|
||||
if err != nil {
|
||||
return err
|
||||
// systemd 不可用,降级到 init.d
|
||||
return m.installInitService(exePath, args)
|
||||
}
|
||||
|
||||
desc := `[Unit]
|
||||
Description=GoEdge HTTPDNS Node Service
|
||||
return m.installSystemdService(systemd, exePath, args)
|
||||
}
|
||||
|
||||
// Start 启动服务
|
||||
func (m *ServiceManager) Start() error {
|
||||
if os.Getgid() != 0 {
|
||||
return errors.New("only root users can start the service")
|
||||
}
|
||||
|
||||
// 优先检查 systemd
|
||||
if fileExists(systemdServiceFile) {
|
||||
systemd, err := executils.LookPath("systemctl")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return executils.NewTimeoutCmd(10*time.Second, systemd, "start", teaconst.SystemdServiceName+".service").Start()
|
||||
}
|
||||
|
||||
// 降级到 init.d
|
||||
if fileExists(initServiceFile) {
|
||||
return executils.NewTimeoutCmd(10*time.Second, "service", teaconst.ProcessName, "start").Start()
|
||||
}
|
||||
|
||||
return errors.New("no service file found, please install the service first")
|
||||
}
|
||||
|
||||
// Uninstall 删除服务
|
||||
func (m *ServiceManager) Uninstall() error {
|
||||
if os.Getgid() != 0 {
|
||||
return errors.New("only root users can uninstall the service")
|
||||
}
|
||||
|
||||
// systemd
|
||||
if fileExists(systemdServiceFile) {
|
||||
systemd, err := executils.LookPath("systemctl")
|
||||
if err == nil {
|
||||
_ = executils.NewTimeoutCmd(10*time.Second, systemd, "stop", teaconst.SystemdServiceName+".service").Run()
|
||||
_ = executils.NewTimeoutCmd(10*time.Second, systemd, "disable", teaconst.SystemdServiceName+".service").Run()
|
||||
_ = executils.NewTimeoutCmd(10*time.Second, systemd, "daemon-reload").Run()
|
||||
}
|
||||
return os.Remove(systemdServiceFile)
|
||||
}
|
||||
|
||||
// init.d
|
||||
if fileExists(initServiceFile) {
|
||||
_ = executils.NewTimeoutCmd(10*time.Second, "service", teaconst.ProcessName, "stop").Run()
|
||||
chkCmd, err := executils.LookPath("chkconfig")
|
||||
if err == nil {
|
||||
_ = executils.NewTimeoutCmd(10*time.Second, chkCmd, "--del", teaconst.ProcessName).Run()
|
||||
}
|
||||
return os.Remove(initServiceFile)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// installSystemdService 安装 systemd 服务
|
||||
func (m *ServiceManager) installSystemdService(systemd, exePath string, args []string) error {
|
||||
shortName := teaconst.SystemdServiceName
|
||||
longName := "GoEdge HTTPDNS"
|
||||
|
||||
// 用 bash 包装启动命令,兼容路径含空格的场景
|
||||
var startCmd = exePath + " daemon"
|
||||
bashPath, _ := executils.LookPath("bash")
|
||||
if len(bashPath) > 0 {
|
||||
startCmd = bashPath + " -c \"" + startCmd + "\""
|
||||
}
|
||||
|
||||
desc := `### BEGIN INIT INFO
|
||||
# Provides: ` + shortName + `
|
||||
# Required-Start: $all
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop:
|
||||
# Short-Description: ` + longName + ` Service
|
||||
### END INIT INFO
|
||||
|
||||
[Unit]
|
||||
Description=` + longName + ` Node Service
|
||||
Before=shutdown.target
|
||||
After=network-online.target
|
||||
|
||||
@@ -32,34 +114,102 @@ After=network-online.target
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=1s
|
||||
ExecStart=` + exePath + ` daemon
|
||||
ExecStart=` + startCmd + `
|
||||
ExecStop=` + exePath + ` stop
|
||||
ExecReload=` + exePath + ` restart
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target`
|
||||
|
||||
err = os.WriteFile(systemdServiceFile, []byte(desc), 0777)
|
||||
// 权限 0644,systemd 单元文件不需要执行权限
|
||||
err := os.WriteFile(systemdServiceFile, []byte(desc), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_ = exec.Command(systemd, "stop", teaconst.SystemdServiceName+".service").Run()
|
||||
_ = exec.Command(systemd, "daemon-reload").Run()
|
||||
return exec.Command(systemd, "enable", teaconst.SystemdServiceName+".service").Run()
|
||||
// 停止已有服务
|
||||
_ = executils.NewTimeoutCmd(10*time.Second, systemd, "stop", shortName+".service").Run()
|
||||
|
||||
// 重新加载
|
||||
_ = executils.NewTimeoutCmd(10*time.Second, systemd, "daemon-reload").Run()
|
||||
|
||||
// 启用开机自启
|
||||
return executils.NewTimeoutCmd(10*time.Second, systemd, "enable", shortName+".service").Run()
|
||||
}
|
||||
|
||||
func (m *ServiceManager) Uninstall() error {
|
||||
if os.Getgid() != 0 {
|
||||
return errors.New("only root users can uninstall the service")
|
||||
}
|
||||
// installInitService 安装 init.d 服务(降级方案,适用于无 systemd 的旧系统)
|
||||
func (m *ServiceManager) installInitService(exePath string, args []string) error {
|
||||
shortName := teaconst.SystemdServiceName
|
||||
longName := "GoEdge HTTPDNS"
|
||||
|
||||
systemd, err := exec.LookPath("systemctl")
|
||||
// 生成 init.d 脚本
|
||||
script := `#!/bin/bash
|
||||
### BEGIN INIT INFO
|
||||
# Provides: ` + shortName + `
|
||||
# Required-Start: $all
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: ` + longName + ` Service
|
||||
### END INIT INFO
|
||||
|
||||
INSTALL_DIR=` + Tea.Root + `
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
cd "${INSTALL_DIR}"
|
||||
` + exePath + ` daemon &
|
||||
echo "` + longName + ` started"
|
||||
;;
|
||||
stop)
|
||||
cd "${INSTALL_DIR}"
|
||||
` + exePath + ` stop
|
||||
echo "` + longName + ` stopped"
|
||||
;;
|
||||
restart)
|
||||
cd "${INSTALL_DIR}"
|
||||
` + exePath + ` stop
|
||||
sleep 1
|
||||
` + exePath + ` daemon &
|
||||
echo "` + longName + ` restarted"
|
||||
;;
|
||||
status)
|
||||
cd "${INSTALL_DIR}"
|
||||
` + exePath + ` status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
exit 0
|
||||
`
|
||||
|
||||
// init.d 脚本需要执行权限
|
||||
err := os.WriteFile(initServiceFile, []byte(script), 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_ = exec.Command(systemd, "disable", teaconst.SystemdServiceName+".service").Run()
|
||||
_ = exec.Command(systemd, "daemon-reload").Run()
|
||||
return os.Remove(systemdServiceFile)
|
||||
// 尝试用 chkconfig 注册(CentOS/RHEL)
|
||||
chkCmd, err := executils.LookPath("chkconfig")
|
||||
if err == nil {
|
||||
_ = executils.NewTimeoutCmd(10*time.Second, chkCmd, "--add", teaconst.ProcessName).Run()
|
||||
return nil
|
||||
}
|
||||
|
||||
// 尝试用 update-rc.d 注册(Debian/Ubuntu)
|
||||
updateRcCmd, err := executils.LookPath("update-rc.d")
|
||||
if err == nil {
|
||||
_ = executils.NewTimeoutCmd(10*time.Second, updateRcCmd, teaconst.ProcessName, "defaults").Run()
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// fileExists 检查文件是否存在
|
||||
func fileExists(path string) bool {
|
||||
_, err := os.Stat(path)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.aliyun.ams.httpdns.demo'
|
||||
namespace 'com.newsdk.ams.httpdns.demo'
|
||||
compileSdkVersion 34
|
||||
buildToolsVersion "30.0.2"
|
||||
defaultConfig {
|
||||
applicationId "com.aliyun.ams.httpdns.demo2"
|
||||
applicationId "com.newsdk.ams.httpdns.demo2"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 34
|
||||
versionCode 1
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
#-renamesourcefileattribute SourceFile
|
||||
-dontwarn okhttp3.**
|
||||
-dontwarn okio.**
|
||||
-dontwarn com.alibaba.sdk.android.httpdns.test.**
|
||||
-dontwarn com.alibaba.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
-dontwarn com.newsdk.sdk.android.httpdns.test.**
|
||||
-dontwarn com.newsdk.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
-keep class com.aliyun.ams.ipdetector.Inet64Util{*;}
|
||||
|
||||
@@ -1,357 +0,0 @@
|
||||
package com.aliyun.ams.httpdns.demo;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.DegradationFilter;
|
||||
import com.alibaba.sdk.android.httpdns.NetType;
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType;
|
||||
import com.alibaba.sdk.android.httpdns.net.HttpDnsNetworkDetector;
|
||||
import com.alibaba.sdk.android.httpdns.ranking.IPRankingBean;
|
||||
import com.aliyun.ams.httpdns.demo.base.BaseActivity;
|
||||
import com.aliyun.ams.httpdns.demo.http.HttpUrlConnectionRequest;
|
||||
import com.aliyun.ams.httpdns.demo.okhttp.OkHttpRequest;
|
||||
import com.aliyun.ams.httpdns.demo.utils.ThreadUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* @author zonglin.nzl
|
||||
* @date 8/30/22
|
||||
*/
|
||||
public class HttpDnsActivity extends BaseActivity {
|
||||
|
||||
public static final String SCHEMA_HTTPS = "https://";
|
||||
public static final String SCHEMA_HTTP = "http://";
|
||||
|
||||
public static final String TAOBAO_URL = "www.taobao.com";
|
||||
public static final String Aliyun_URL = "www.Aliyun.com";
|
||||
|
||||
public static final String[] hosts = new String[]{
|
||||
TAOBAO_URL, Aliyun_URL
|
||||
};
|
||||
|
||||
public static String getUrl(String schema, String host) {
|
||||
return schema + host;
|
||||
}
|
||||
|
||||
/**
|
||||
* 瑕佽姹傜殑schema
|
||||
*/
|
||||
private String schema = SCHEMA_HTTPS;
|
||||
/**
|
||||
* 瑕佽姹傜殑鍩熷悕
|
||||
*/
|
||||
private String host = Aliyun_URL;
|
||||
/**
|
||||
* 瑕佽В鏋愮殑ip绫诲瀷
|
||||
*/
|
||||
private RequestIpType requestIpType = RequestIpType.v4;
|
||||
|
||||
private HttpUrlConnectionRequest httpUrlConnectionRequest;
|
||||
private OkHttpRequest okHttpRequest;
|
||||
private NetworkRequest networkRequest = httpUrlConnectionRequest;
|
||||
|
||||
private ExecutorService worker = Executors.newSingleThreadExecutor();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
httpUrlConnectionRequest = new HttpUrlConnectionRequest(this);
|
||||
okHttpRequest = new OkHttpRequest(this);
|
||||
networkRequest = httpUrlConnectionRequest;
|
||||
|
||||
addFourButton("鍒囨崲瀹炰緥", v -> {
|
||||
MyApp.getInstance().changeHolder();
|
||||
sendLog("httpdns瀹炰緥宸插垏鎹?);
|
||||
}, "鑾峰彇閰嶇疆", v -> {
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getCurrentConfig());
|
||||
sendLog("瑕佽В鏋愮殑鍩熷悕鏄? + host);
|
||||
sendLog("瑕佽В鏋愮殑ip绫诲瀷鏄? + requestIpType.name());
|
||||
sendLog("瑕佹ā鎷熻姹傜殑url鏄? + getUrl(schema, host));
|
||||
sendLog("妯℃嫙璇锋眰鐨勭綉缁滄鏋舵槸" + (networkRequest == httpUrlConnectionRequest ? " HttpUrlConnection" : "OkHttp"));
|
||||
}, "娓呴櫎閰嶇疆缂撳瓨", v -> {
|
||||
MyApp.getInstance().getCurrentHolder().cleanSp();
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "閰嶇疆缂撳瓨娓呴櫎, 閲嶅惎鐢熸晥");
|
||||
}, "娓呴櫎鏃ュ織", v -> cleanLog());
|
||||
|
||||
addTwoButton("寮€鍚痟ttps", v -> {
|
||||
MyApp.getInstance().getCurrentHolder().setEnableHttps(true);
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "寮€鍚痟ttps");
|
||||
}, "鍏抽棴https", v -> {
|
||||
MyApp.getInstance().getCurrentHolder().setEnableHttps(false);
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "鍏抽棴https");
|
||||
});
|
||||
|
||||
addTwoButton("鍏佽杩囨湡IP", v -> {
|
||||
MyApp.getInstance().getCurrentHolder().setEnableExpiredIp(true);
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "鍏佽杩囨湡IP");
|
||||
}, "涓嶅厑璁歌繃鏈烮P", v -> {
|
||||
MyApp.getInstance().getCurrentHolder().setEnableExpiredIp(false);
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "涓嶅厑璁歌繃鏈烮P");
|
||||
});
|
||||
|
||||
|
||||
addTwoButton("鍏佽鎸佷箙鍖栫紦瀛?, v -> {
|
||||
MyApp.getInstance().getCurrentHolder().setEnableCacheIp(true);
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "鍏佽鎸佷箙鍖栫紦瀛?);
|
||||
}, "涓嶅厑璁告寔涔呭寲缂撳瓨", v -> {
|
||||
MyApp.getInstance().getCurrentHolder().setEnableCacheIp(false);
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "涓嶅厑璁告寔涔呭寲缂撳瓨");
|
||||
});
|
||||
|
||||
addThreeButton("璁剧疆涓浗澶ч檰", v -> {
|
||||
MyApp.getInstance().getCurrentHolder().setRegion(null);
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "鍒囨崲鍒颁腑鍥藉ぇ闄?);
|
||||
}, "璁剧疆涓浗棣欐腐", v -> {
|
||||
MyApp.getInstance().getCurrentHolder().setRegion("hk");
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "鍒囨崲鍒颁腑鍥介娓?);
|
||||
}, "璁剧疆鏂板姞鍧?, v -> {
|
||||
MyApp.getInstance().getCurrentHolder().setRegion("sg");
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "鍒囨崲鍒版柊鍔犲潯");
|
||||
});
|
||||
|
||||
addEditTextButton("瓒呮椂鏃堕暱 ms", "璁剧疆瓒呮椂ms", view -> {
|
||||
EditText et = (EditText) view;
|
||||
int timeout = Integer.parseInt(et.getEditableText().toString());
|
||||
MyApp.getInstance().getCurrentHolder().setTimeout(timeout);
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "璁剧疆瓒呮椂 " + timeout);
|
||||
});
|
||||
|
||||
addTwoButton("寮€鍚檷绾?, v -> {
|
||||
// 娉ㄦ剰锛氶檷绾ц繃婊ゅ櫒鐜板湪闇€瑕侀€氳繃InitConfig璁剧疆锛岄噸鍚簲鐢ㄧ敓鏁?
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "闄嶇骇鍔熻兘闇€瑕侀€氳繃InitConfig閰嶇疆");
|
||||
}, "鍏抽棴闄嶇骇", v -> {
|
||||
// 娉ㄦ剰锛氶檷绾ц繃婊ゅ櫒鐜板湪闇€瑕侀€氳繃InitConfig璁剧疆锛岄噸鍚簲鐢ㄧ敓鏁?
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "闄嶇骇鍔熻兘闇€瑕侀€氳繃InitConfig閰嶇疆");
|
||||
});
|
||||
|
||||
addTwoButton("寮€鍚綉缁滃彉鍖栧悗棰勮В鏋?, v -> {
|
||||
// 娉ㄦ剰锛氭鍔熻兘鐜板湪闇€瑕侀€氳繃InitConfig璁剧疆锛岄噸鍚簲鐢ㄧ敓鏁?
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "缃戠粶鍙樺寲鍚庨瑙f瀽闇€瑕侀€氳繃InitConfig閰嶇疆");
|
||||
}, "鍏抽棴缃戠粶鍙樺寲鍚庨瑙f瀽", v -> {
|
||||
// 娉ㄦ剰锛氭鍔熻兘鐜板湪闇€瑕侀€氳繃InitConfig璁剧疆锛岄噸鍚簲鐢ㄧ敓鏁?
|
||||
sendLog(MyApp.getInstance().getCurrentHolder().getAccountId() + "缃戠粶鍙樺寲鍚庨瑙f瀽闇€瑕侀€氳繃InitConfig閰嶇疆");
|
||||
});
|
||||
|
||||
addView(R.layout.item_autocomplete_edittext_button, view -> {
|
||||
final AutoCompleteTextView actvOne = view.findViewById(R.id.actvOne);
|
||||
final EditText etOne = view.findViewById(R.id.etOne);
|
||||
Button btnOne = view.findViewById(R.id.btnOne);
|
||||
|
||||
actvOne.setHint("璇疯緭鍏ュ煙鍚?);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(),
|
||||
android.R.layout.simple_dropdown_item_1line, hosts);
|
||||
actvOne.setAdapter(adapter);
|
||||
|
||||
etOne.setHint("璇疯緭鍏ヨ嚜瀹氫箟ttl");
|
||||
|
||||
btnOne.setText("鎸囧畾鍩熷悕ttl s");
|
||||
btnOne.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String host = actvOne.getEditableText().toString();
|
||||
int ttl = Integer.parseInt(etOne.getEditableText().toString());
|
||||
MyApp.getInstance().getCurrentHolder().setHostTtl(host, ttl);
|
||||
sendLog("鎸囧畾鍩熷悕" + host + "鐨則tl涓? + ttl + "绉?);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
addView(R.layout.item_autocomplete_edittext_button, view -> {
|
||||
final AutoCompleteTextView actvOne = view.findViewById(R.id.actvOne);
|
||||
final EditText etOne = view.findViewById(R.id.etOne);
|
||||
Button btnOne = view.findViewById(R.id.btnOne);
|
||||
|
||||
actvOne.setHint("鍩熷悕");
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(getApplicationContext(),
|
||||
android.R.layout.simple_dropdown_item_1line, hosts);
|
||||
actvOne.setAdapter(adapter);
|
||||
|
||||
etOne.setHint("璇疯緭鍏ョ鍙?);
|
||||
|
||||
btnOne.setText("娣诲姞ipRanking閰嶇疆");
|
||||
btnOne.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String host = actvOne.getEditableText().toString();
|
||||
int port = Integer.parseInt(etOne.getEditableText().toString());
|
||||
MyApp.getInstance().getCurrentHolder().addIpProbeItem(new IPRankingBean(host, port));
|
||||
sendLog("娣诲姞鍩熷悕" + host + " 鎺㈡祴");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
addAutoCompleteTextViewButton(hosts, "涓荤珯鍩熷悕", "娣诲姞涓荤珯鍩熷悕", view -> {
|
||||
AutoCompleteTextView actvOne = (AutoCompleteTextView) view;
|
||||
String host = actvOne.getEditableText().toString();
|
||||
MyApp.getInstance().getCurrentHolder().addHostWithFixedIp(host);
|
||||
sendLog("娣诲姞涓荤珯鍩熷悕" + host);
|
||||
});
|
||||
|
||||
addAutoCompleteTextViewButton(hosts, "鍩熷悕", "鍒犻櫎鎸囧畾鍩熷悕鐨勭紦瀛?, view -> {
|
||||
AutoCompleteTextView actvOne = (AutoCompleteTextView) view;
|
||||
String host = actvOne.getEditableText().toString();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(host);
|
||||
MyApp.getInstance().getService().cleanHostCache(list);
|
||||
sendLog("娓呴櫎鎸囧畾host鐨勭紦瀛? + host);
|
||||
});
|
||||
|
||||
addOneButton("娓呴櫎鎵€鏈夌紦瀛?, v -> {
|
||||
MyApp.getInstance().getService().cleanHostCache(null);
|
||||
sendLog("娓呴櫎鎵€鏈夌紦瀛?);
|
||||
});
|
||||
|
||||
addFourButton("鑾峰彇褰撳墠缃戠粶鐘舵€?, v -> {
|
||||
NetType type = HttpDnsNetworkDetector.getInstance().getNetType(getApplicationContext());
|
||||
sendLog("鑾峰彇缃戠粶鐘舵€?" + type.name());
|
||||
}, "绂佺敤缃戠粶鐘舵€佺紦瀛?, v -> {
|
||||
HttpDnsNetworkDetector.getInstance().disableCache(true);
|
||||
sendLog("缃戠粶鐘舵€?绂佺敤缂撳瓨 ");
|
||||
}, "寮€鍚綉缁滅姸鎬佺紦瀛?, v -> {
|
||||
HttpDnsNetworkDetector.getInstance().disableCache(false);
|
||||
sendLog("缃戠粶鐘舵€?寮€鍚紦瀛?");
|
||||
}, "娓呴櫎缃戠粶鐘舵€佺紦瀛?, v -> {
|
||||
HttpDnsNetworkDetector.getInstance().cleanCache(false);
|
||||
sendLog("缃戠粶鐘舵€佹竻闄ょ紦瀛?");
|
||||
});
|
||||
|
||||
addTwoButton("绂佹璇诲彇IP", v -> {
|
||||
HttpDnsNetworkDetector.getInstance().setCheckInterface(false);
|
||||
sendLog("鏌ヨ缃戠粶鐘舵€佹椂 绂佹璇诲彇IP");
|
||||
}, "鍏佽璇诲彇IP", v -> {
|
||||
HttpDnsNetworkDetector.getInstance().setCheckInterface(true);
|
||||
sendLog("鏌ヨ缃戠粶鐘舵€佹椂 鍏佽璇诲彇IP");
|
||||
});
|
||||
|
||||
addAutoCompleteTextViewButton(hosts, "鍩熷悕", "璁剧疆妫€娴嬬綉缁滀娇鐢ㄧ殑鍩熷悕", view -> {
|
||||
AutoCompleteTextView actvOne = (AutoCompleteTextView) view;
|
||||
String host = actvOne.getEditableText().toString();
|
||||
HttpDnsNetworkDetector.getInstance().setHostToCheckNetType(host);
|
||||
sendLog("璁剧疆妫€娴嬬綉缁滅姸鎬佷娇鐢ㄧ殑鍩熷悕涓? + host);
|
||||
});
|
||||
|
||||
addTwoButton("妯℃嫙璇锋眰浣跨敤https璇锋眰", v -> {
|
||||
schema = SCHEMA_HTTPS;
|
||||
sendLog("娴嬭瘯url浣跨敤https");
|
||||
}, "妯℃嫙璇锋眰浣跨敤http璇锋眰", v -> {
|
||||
schema = SCHEMA_HTTP;
|
||||
sendLog("娴嬭瘯url浣跨敤http");
|
||||
});
|
||||
|
||||
addTwoButton("HttpUrlConnection", v -> {
|
||||
networkRequest = httpUrlConnectionRequest;
|
||||
sendLog("鎸囧畾缃戠粶瀹炵幇鏂瑰紡涓篐ttpUrlConnection");
|
||||
}, "Okhttp", v -> {
|
||||
networkRequest = okHttpRequest;
|
||||
sendLog("鎸囧畾缃戠粶瀹炵幇鏂瑰紡涓簅khttp");
|
||||
});
|
||||
|
||||
|
||||
addFourButton("鎸囧畾v4", v -> {
|
||||
requestIpType = RequestIpType.v4;
|
||||
sendLog("瑕佽В鏋愮殑IP绫诲瀷鎸囧畾涓篿pv4");
|
||||
}, "鎸囧畾v6", v -> {
|
||||
requestIpType = RequestIpType.v6;
|
||||
sendLog("瑕佽В鏋愮殑IP绫诲瀷鎸囧畾涓篿pv6");
|
||||
}, "閮借В鏋?, v -> {
|
||||
requestIpType = RequestIpType.both;
|
||||
sendLog("瑕佽В鏋愮殑IP绫诲瀷鎸囧畾涓篿pv4鍜宨pv6");
|
||||
}, "鑷姩鍒ゆ柇", v -> {
|
||||
requestIpType = RequestIpType.auto;
|
||||
sendLog("瑕佽В鏋愮殑IP绫诲瀷鏍规嵁缃戠粶鎯呭喌鑷姩鍒ゆ柇");
|
||||
});
|
||||
|
||||
addAutoCompleteTextViewButton(hosts, "鍩熷悕", "鎸囧畾瑕佽В鏋愮殑鍩熷悕", new OnButtonClick() {
|
||||
@Override
|
||||
public void onBtnClick(View view) {
|
||||
AutoCompleteTextView actvOne = (AutoCompleteTextView) view;
|
||||
host = actvOne.getEditableText().toString();
|
||||
sendLog("瑕佽В鏋愮殑鍩熷悕" + host);
|
||||
}
|
||||
});
|
||||
|
||||
addTwoButton("寮傛瑙f瀽", v -> worker.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendLog("寮€濮嬪彂璧风綉缁滆姹?);
|
||||
sendLog("缃戠粶瀹炵幇鏂瑰紡涓? + (networkRequest == httpUrlConnectionRequest ? "HttpUrlConnection" : "okhttp"));
|
||||
String url = getUrl(schema, host);
|
||||
sendLog("url is " + url);
|
||||
sendLog("httpdns 浣跨敤 寮傛瑙f瀽api");
|
||||
sendLog("鎸囧畾瑙f瀽ip绫诲瀷涓? + requestIpType.name());
|
||||
networkRequest.updateHttpDnsConfig(true, requestIpType);
|
||||
try {
|
||||
String response = networkRequest.httpGet(url);
|
||||
if (response != null && response.length() > 30) {
|
||||
response = response.trim();
|
||||
if (response.length() > 30) {
|
||||
response = response.substring(0, 30) + "...";
|
||||
}
|
||||
}
|
||||
sendLog("璇锋眰缁撴潫 response is " + response + " 瀹屾暣璁板綍璇风湅logcat鏃ュ織");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sendLog("璇锋眰缁撴潫 鍙戠敓寮傚父 " + e.getClass().getName() + e.getMessage() + " 瀹屾暣璁板綍璇风湅logcat鏃ュ織");
|
||||
}
|
||||
|
||||
}
|
||||
}), "鍚屾瑙f瀽", v -> worker.execute(() -> {
|
||||
sendLog("寮€濮嬪彂璧风綉缁滆姹?);
|
||||
sendLog("缃戠粶瀹炵幇鏂瑰紡涓? + (networkRequest == httpUrlConnectionRequest ? "HttpUrlConnection" : "okhttp"));
|
||||
String url = getUrl(schema, host);
|
||||
sendLog("url is " + url);
|
||||
sendLog("httpdns 浣跨敤 鍚屾瑙f瀽api");
|
||||
sendLog("鎸囧畾瑙f瀽ip绫诲瀷涓? + requestIpType.name());
|
||||
networkRequest.updateHttpDnsConfig(false, requestIpType);
|
||||
try {
|
||||
String response = networkRequest.httpGet(url);
|
||||
if (response != null && response.length() > 30) {
|
||||
response = response.substring(0, 30) + "...";
|
||||
}
|
||||
sendLog("璇锋眰缁撴潫 response is " + response + " 瀹屾暣璁板綍璇风湅logcat鏃ュ織");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sendLog("璇锋眰缁撴潫 鍙戠敓寮傚父 " + e.getClass().getName() + e.getMessage() + " 瀹屾暣璁板綍璇风湅logcat鏃ュ織");
|
||||
}
|
||||
}));
|
||||
|
||||
addThreeButton("鍙戣捣棰勮В鏋?, v -> worker.execute(() -> {
|
||||
ArrayList<String> tmp = new ArrayList<>();
|
||||
Collections.addAll(tmp, hosts);
|
||||
MyApp.getInstance().getService().setPreResolveHosts(tmp, requestIpType);
|
||||
sendLog("宸插彂璧烽瑙f瀽璇锋眰");
|
||||
}), "璺宠浆SDNS娴嬭瘯鐣岄潰",
|
||||
v -> startActivity(new Intent(HttpDnsActivity.this, SDNSActivity.class)), "璺宠浆Webview娴嬭瘯鐣岄潰", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(HttpDnsActivity.this, WebViewActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
final String[] validHosts = new String[]{
|
||||
"www.Aliyun.com",
|
||||
"www.taobao.com"
|
||||
};
|
||||
|
||||
addTwoButton("骞跺彂寮傛璇锋眰", v -> {
|
||||
ThreadUtil.multiThreadTest(validHosts, 100, 20, 10 * 60 * 1000, true, requestIpType);
|
||||
sendLog("寮傛api骞跺彂娴嬭瘯寮€濮嬶紝澶х害鑰楁椂10鍒嗛挓锛岃鏈€鍚庢煡鐪媗ogcat鏃ュ織锛岀‘璁ょ粨鏋滐紝寤鸿鍏抽棴httpdns鏃ュ織锛岄伩鍏嶆棩蹇楅噺杩囧ぇ");
|
||||
}, "骞跺彂鍚屾璇锋眰", v -> {
|
||||
ThreadUtil.multiThreadTest(validHosts, 100, 20, 10 * 60 * 1000, false, requestIpType);
|
||||
sendLog("鍚屾api骞跺彂娴嬭瘯寮€濮嬶紝澶х害鑰楁椂10鍒嗛挓锛岃鏈€鍚庢煡鐪媗ogcat鏃ュ織锛岀‘璁ょ粨鏋滐紝寤鸿鍏抽棴httpdns鏃ュ織锛岄伩鍏嶆棩蹇楅噺杩囧ぇ");
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
package com.aliyun.ams.httpdns.demo;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.HTTPDNSResult;
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType;
|
||||
import com.aliyun.ams.httpdns.demo.base.BaseActivity;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.aliyun.ams.httpdns.demo.HttpDnsActivity.Aliyun_URL;
|
||||
|
||||
public class SDNSActivity extends BaseActivity {
|
||||
|
||||
private final HashMap<String, String> globalParams = new HashMap<>();
|
||||
/**
|
||||
* 瑕佽姹傜殑鍩熷悕
|
||||
*/
|
||||
private String host = HttpDnsActivity.Aliyun_URL;
|
||||
/**
|
||||
* 瑕佽В鏋愮殑ip绫诲瀷
|
||||
*/
|
||||
private RequestIpType requestIpType = RequestIpType.v4;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addEditTextEditTextButton("key", "value", "娣诲姞鍏ㄥ眬閰嶇疆", new OnButtonClickMoreView() {
|
||||
@Override
|
||||
public void onBtnClick(View[] views) {
|
||||
EditText etOne = (EditText) views[0];
|
||||
EditText etTwo = (EditText) views[1];
|
||||
|
||||
String key = etOne.getEditableText().toString();
|
||||
String value = etTwo.getEditableText().toString();
|
||||
|
||||
globalParams.put(key, value);
|
||||
|
||||
// 娉ㄦ剰锛歋DNS鍏ㄥ眬鍙傛暟鐜板湪闇€瑕侀€氳繃InitConfig璁剧疆锛岄噸鍚簲鐢ㄧ敓鏁?
|
||||
sendLog("娣诲姞鍏ㄥ眬鍙傛暟 " + key + " : " + value);
|
||||
}
|
||||
});
|
||||
|
||||
addOneButton("娓呴櫎鍏ㄥ眬閰嶇疆", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
globalParams.clear();
|
||||
// 娉ㄦ剰锛歋DNS鍏ㄥ眬鍙傛暟鐜板湪闇€瑕侀€氳繃InitConfig璁剧疆锛岄噸鍚簲鐢ㄧ敓鏁?
|
||||
sendLog("娓呴櫎鍏ㄥ眬鍙傛暟");
|
||||
}
|
||||
});
|
||||
|
||||
addFourButton("鎸囧畾v4", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
requestIpType = RequestIpType.v4;
|
||||
sendLog("瑕佽В鏋愮殑IP绫诲瀷鎸囧畾涓篿pv4");
|
||||
}
|
||||
}, "鎸囧畾v6", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
requestIpType = RequestIpType.v6;
|
||||
sendLog("瑕佽В鏋愮殑IP绫诲瀷鎸囧畾涓篿pv6");
|
||||
}
|
||||
}, "閮借В鏋?, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
requestIpType = RequestIpType.both;
|
||||
sendLog("瑕佽В鏋愮殑IP绫诲瀷鎸囧畾涓篿pv4鍜宨pv6");
|
||||
}
|
||||
}, "鑷姩鍒ゆ柇", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
requestIpType = RequestIpType.auto;
|
||||
sendLog("瑕佽В鏋愮殑IP绫诲瀷鏍规嵁缃戠粶鎯呭喌鑷姩鍒ゆ柇");
|
||||
}
|
||||
});
|
||||
|
||||
addAutoCompleteTextViewButton(HttpDnsActivity.hosts, "鍩熷悕", "鎸囧畾瑕佽В鏋愮殑鍩熷悕", new OnButtonClick() {
|
||||
@Override
|
||||
public void onBtnClick(View view) {
|
||||
AutoCompleteTextView actvOne = (AutoCompleteTextView) view;
|
||||
host = actvOne.getEditableText().toString();
|
||||
sendLog("瑕佽В鏋愮殑鍩熷悕" + host);
|
||||
}
|
||||
});
|
||||
|
||||
addEditTextEditTextButton("key", "value", "鍙戣捣璇锋眰", new OnButtonClickMoreView() {
|
||||
@Override
|
||||
public void onBtnClick(View[] views) {
|
||||
EditText etOne = (EditText) views[0];
|
||||
EditText etTwo = (EditText) views[1];
|
||||
|
||||
String key = etOne.getEditableText().toString();
|
||||
String value = etTwo.getEditableText().toString();
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
map.put(key, value);
|
||||
|
||||
sendLog("鍙戣捣SDNS璇锋眰 requestIpType is " + requestIpType.name());
|
||||
HTTPDNSResult result = MyApp.getInstance().getService().getIpsByHostAsync(host, requestIpType, map, "娴嬭瘯SDNS");
|
||||
sendLog("缁撴灉 " + result);
|
||||
}
|
||||
});
|
||||
|
||||
addTwoButton("scale1鍙傛暟璇锋眰", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("scale", "scale1");
|
||||
sendLog("鍙戣捣SDNS璇锋眰 requestIpType is " + requestIpType.name() + " scale : scale1");
|
||||
HTTPDNSResult result = MyApp.getInstance().getService().getIpsByHostAsync(host, requestIpType, map, "娴嬭瘯1");
|
||||
sendLog("缁撴灉 " + result);
|
||||
}
|
||||
}, "scale2鍙傛暟璇锋眰", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("scale", "scale2");
|
||||
sendLog("鍙戣捣SDNS璇锋眰 requestIpType is " + requestIpType.name() + " scale : scale2");
|
||||
HTTPDNSResult result = MyApp.getInstance().getService().getIpsByHostAsync(host, requestIpType, map, "娴嬭瘯2");
|
||||
sendLog("缁撴灉 " + result);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
package com.aliyun.ams.httpdns.demo.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.HTTPDNSResult;
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType;
|
||||
import com.alibaba.sdk.android.httpdns.SyncService;
|
||||
|
||||
import com.aliyun.ams.httpdns.demo.MyApp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class ThreadUtil {
|
||||
|
||||
public static void multiThreadTest(final String[] validHosts, final int hostCount,
|
||||
final int threadCount, final int executeTime,
|
||||
final boolean async, final RequestIpType type) {
|
||||
int validCount = validHosts.length;
|
||||
if (validCount > hostCount) {
|
||||
validCount = hostCount;
|
||||
}
|
||||
final int tmpValidCount = validCount;
|
||||
Log.d(MyApp.TAG,
|
||||
threadCount + "绾跨▼骞跺彂锛屾墽琛? + executeTime + ", 鎬诲煙鍚? + hostCount + "涓紝鏈夋晥"
|
||||
+ validCount + "涓?);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final ArrayList<String> hosts = new ArrayList<>(hostCount);
|
||||
for (int i = 0; i < hostCount - tmpValidCount; i++) {
|
||||
hosts.add("test" + i + ".Aliyun.com");
|
||||
}
|
||||
hosts.addAll(Arrays.asList(validHosts).subList(0, tmpValidCount));
|
||||
|
||||
final CountDownLatch testLatch = new CountDownLatch(threadCount);
|
||||
ExecutorService service = Executors.newFixedThreadPool(threadCount);
|
||||
final CountDownLatch countDownLatch = new CountDownLatch(threadCount);
|
||||
for (int i = 0; i < threadCount; i++) {
|
||||
service.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
countDownLatch.countDown();
|
||||
try {
|
||||
countDownLatch.await();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Random random = new Random(Thread.currentThread().getId());
|
||||
int allRequestCount = 0;
|
||||
int slowRequestCount = 0;
|
||||
int emptyResponseCount = 0;
|
||||
long maxSlowRequestTime = 0;
|
||||
long subSlowRequestTime = 0;
|
||||
int taobaoCount = 0;
|
||||
int taobaoSuccessCount = 0;
|
||||
long firstTaobaoTime = 0;
|
||||
long firstTaobaoSuccessTime = 0;
|
||||
long begin = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - begin < executeTime) {
|
||||
String host = hosts.get(random.nextInt(hostCount));
|
||||
long startRequestTime = System.currentTimeMillis();
|
||||
HTTPDNSResult ips = null;
|
||||
if (async) {
|
||||
ips = MyApp.getInstance().getService().getIpsByHostAsync(host,
|
||||
type);
|
||||
} else {
|
||||
ips =
|
||||
((SyncService)MyApp.getInstance().getService()).getByHost(
|
||||
host, type);
|
||||
}
|
||||
long endRequestTime = System.currentTimeMillis();
|
||||
if (host.equals("www.taobao.com")) {
|
||||
if (taobaoCount == 0) {
|
||||
firstTaobaoTime = System.currentTimeMillis();
|
||||
}
|
||||
taobaoCount++;
|
||||
if (ips.getIps() != null && ips.getIps().length > 0) {
|
||||
if (taobaoSuccessCount == 0) {
|
||||
firstTaobaoSuccessTime = System.currentTimeMillis();
|
||||
}
|
||||
taobaoSuccessCount++;
|
||||
}
|
||||
}
|
||||
if (endRequestTime - startRequestTime > 100) {
|
||||
slowRequestCount++;
|
||||
subSlowRequestTime += endRequestTime - startRequestTime;
|
||||
if (maxSlowRequestTime < endRequestTime - startRequestTime) {
|
||||
maxSlowRequestTime = endRequestTime - startRequestTime;
|
||||
}
|
||||
}
|
||||
if (ips == null || ips.getIps() == null
|
||||
|| ips.getIps().length == 0) {
|
||||
emptyResponseCount++;
|
||||
}
|
||||
allRequestCount++;
|
||||
}
|
||||
|
||||
String msg = Thread.currentThread().getId() + " allRequestCount: "
|
||||
+ allRequestCount + ", slowRequestCount: " + slowRequestCount
|
||||
+ ", emptyResponseCount: " + emptyResponseCount
|
||||
+ ", maxSlowRequestTime : " + maxSlowRequestTime
|
||||
+ ", avgSlowRequestTime: " + (slowRequestCount == 0 ? 0
|
||||
: subSlowRequestTime / slowRequestCount)
|
||||
+ ", taoRequestCount: " + taobaoCount + ", "
|
||||
+ "taoSuccessRequestCount: "
|
||||
+ taobaoSuccessCount + ", firstTaoRequestTime: " + (firstTaobaoTime
|
||||
- begin) + ", firstSuccessTaoRequestTime: " + (
|
||||
firstTaobaoSuccessTime - begin);
|
||||
Log.w(MyApp.TAG, "asyncMulti " + msg);
|
||||
testLatch.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
testLatch.await();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.newsdk.ams.httpdns.demo;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType;
|
||||
import com.newsdk.ams.httpdns.demo.base.BaseActivity;
|
||||
import com.newsdk.ams.httpdns.demo.http.HttpUrlConnectionRequest;
|
||||
import com.newsdk.ams.httpdns.demo.okhttp.OkHttpRequest;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class HttpDnsActivity extends BaseActivity {
|
||||
|
||||
private static final String SCHEMA_HTTPS = "https://";
|
||||
private static final String SCHEMA_HTTP = "http://";
|
||||
|
||||
private static final String[] HOSTS = new String[] {
|
||||
"www.taobao.com",
|
||||
"www.Aliyun.com"
|
||||
};
|
||||
|
||||
private String schema = SCHEMA_HTTPS;
|
||||
private String host = HOSTS[0];
|
||||
private RequestIpType requestIpType = RequestIpType.v4;
|
||||
|
||||
private HttpUrlConnectionRequest httpUrlConnectionRequest;
|
||||
private OkHttpRequest okHttpRequest;
|
||||
private NetworkRequest networkRequest;
|
||||
|
||||
private final ExecutorService worker = Executors.newSingleThreadExecutor();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
httpUrlConnectionRequest = new HttpUrlConnectionRequest(this);
|
||||
okHttpRequest = new OkHttpRequest(this);
|
||||
networkRequest = httpUrlConnectionRequest;
|
||||
|
||||
addFourButton(
|
||||
"Switch instance",
|
||||
v -> {
|
||||
MyApp.getInstance().changeHolder();
|
||||
sendLog("Instance switched.");
|
||||
},
|
||||
"Show config",
|
||||
v -> sendLog(MyApp.getInstance().getCurrentHolder().getCurrentConfig()),
|
||||
"Clear holder cache",
|
||||
v -> {
|
||||
MyApp.getInstance().getCurrentHolder().cleanSp();
|
||||
sendLog("Holder cache cleared.");
|
||||
},
|
||||
"Clear log",
|
||||
v -> cleanLog()
|
||||
);
|
||||
|
||||
addAutoCompleteTextViewButton(HOSTS, "Host", "Set host", view -> {
|
||||
AutoCompleteTextView actv = (AutoCompleteTextView) view;
|
||||
host = actv.getEditableText().toString();
|
||||
sendLog("Host set to: " + host);
|
||||
});
|
||||
|
||||
addTwoButton(
|
||||
"Use HTTPS",
|
||||
v -> {
|
||||
schema = SCHEMA_HTTPS;
|
||||
sendLog("Schema set to HTTPS.");
|
||||
},
|
||||
"Use HTTP",
|
||||
v -> {
|
||||
schema = SCHEMA_HTTP;
|
||||
sendLog("Schema set to HTTP.");
|
||||
}
|
||||
);
|
||||
|
||||
addFourButton(
|
||||
"IP type v4",
|
||||
v -> {
|
||||
requestIpType = RequestIpType.v4;
|
||||
sendLog("Request IP type: v4");
|
||||
},
|
||||
"IP type v6",
|
||||
v -> {
|
||||
requestIpType = RequestIpType.v6;
|
||||
sendLog("Request IP type: v6");
|
||||
},
|
||||
"IP type both",
|
||||
v -> {
|
||||
requestIpType = RequestIpType.both;
|
||||
sendLog("Request IP type: both");
|
||||
},
|
||||
"IP type auto",
|
||||
v -> {
|
||||
requestIpType = RequestIpType.auto;
|
||||
sendLog("Request IP type: auto");
|
||||
}
|
||||
);
|
||||
|
||||
addTwoButton(
|
||||
"HttpUrlConnection",
|
||||
v -> {
|
||||
networkRequest = httpUrlConnectionRequest;
|
||||
sendLog("Network stack: HttpUrlConnection");
|
||||
},
|
||||
"OkHttp",
|
||||
v -> {
|
||||
networkRequest = okHttpRequest;
|
||||
sendLog("Network stack: OkHttp");
|
||||
}
|
||||
);
|
||||
|
||||
addTwoButton(
|
||||
"Resolve sync",
|
||||
v -> worker.execute(() -> executeResolve(false)),
|
||||
"Resolve async",
|
||||
v -> worker.execute(() -> executeResolve(true))
|
||||
);
|
||||
|
||||
addTwoButton(
|
||||
"Open SDNS page",
|
||||
v -> startActivity(new Intent(HttpDnsActivity.this, SDNSActivity.class)),
|
||||
"Open WebView page",
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(HttpDnsActivity.this, WebViewActivity.class));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
worker.shutdownNow();
|
||||
}
|
||||
|
||||
private void executeResolve(boolean async) {
|
||||
String url = schema + host;
|
||||
sendLog("Request URL: " + url);
|
||||
sendLog("Request IP type: " + requestIpType.name());
|
||||
sendLog("Async mode: " + async);
|
||||
sendLog("Stack: " + (networkRequest == httpUrlConnectionRequest ? "HttpUrlConnection" : "OkHttp"));
|
||||
try {
|
||||
networkRequest.updateHttpDnsConfig(async, requestIpType);
|
||||
String response = networkRequest.httpGet(url);
|
||||
if (response != null && response.length() > 120) {
|
||||
response = response.substring(0, 120) + "...";
|
||||
}
|
||||
sendLog("Response: " + response);
|
||||
} catch (Exception e) {
|
||||
sendLog("Request failed: " + e.getClass().getSimpleName() + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.aliyun.ams.httpdns.demo;
|
||||
package com.newsdk.ams.httpdns.demo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.CacheTtlChanger;
|
||||
import com.alibaba.sdk.android.httpdns.HttpDns;
|
||||
import com.alibaba.sdk.android.httpdns.HttpDnsService;
|
||||
import com.alibaba.sdk.android.httpdns.InitConfig;
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType;
|
||||
import com.alibaba.sdk.android.httpdns.ranking.IPRankingBean;
|
||||
import com.aliyun.ams.httpdns.demo.utils.SpUtil;
|
||||
import com.newsdk.sdk.android.httpdns.CacheTtlChanger;
|
||||
import com.newsdk.sdk.android.httpdns.HttpDns;
|
||||
import com.newsdk.sdk.android.httpdns.HttpDnsService;
|
||||
import com.newsdk.sdk.android.httpdns.InitConfig;
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType;
|
||||
import com.newsdk.sdk.android.httpdns.ranking.IPRankingBean;
|
||||
import com.newsdk.ams.httpdns.demo.utils.SpUtil;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.aliyun.ams.httpdns.demo;
|
||||
package com.newsdk.ams.httpdns.demo;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.HttpDnsService;
|
||||
import com.alibaba.sdk.android.httpdns.ILogger;
|
||||
import com.alibaba.sdk.android.httpdns.log.HttpDnsLog;
|
||||
import com.aliyun.ams.httpdns.demo.utils.SpUtil;
|
||||
import com.newsdk.sdk.android.httpdns.HttpDnsService;
|
||||
import com.newsdk.sdk.android.httpdns.ILogger;
|
||||
import com.newsdk.sdk.android.httpdns.log.HttpDnsLog;
|
||||
import com.newsdk.ams.httpdns.demo.utils.SpUtil;
|
||||
|
||||
public class MyApp extends Application {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.aliyun.ams.httpdns.demo;
|
||||
package com.newsdk.ams.httpdns.demo;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType;
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType;
|
||||
|
||||
public interface NetworkRequest {
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.newsdk.ams.httpdns.demo;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.newsdk.sdk.android.httpdns.HTTPDNSResult;
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType;
|
||||
import com.newsdk.ams.httpdns.demo.base.BaseActivity;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class SDNSActivity extends BaseActivity {
|
||||
|
||||
private static final String[] HOSTS = new String[] {
|
||||
"www.Aliyun.com",
|
||||
"www.taobao.com"
|
||||
};
|
||||
|
||||
private final HashMap<String, String> globalParams = new HashMap<>();
|
||||
private String host = HOSTS[0];
|
||||
private RequestIpType requestIpType = RequestIpType.v4;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
addEditTextEditTextButton("key", "value", "Add global param", new OnButtonClickMoreView() {
|
||||
@Override
|
||||
public void onBtnClick(View[] views) {
|
||||
EditText keyView = (EditText) views[0];
|
||||
EditText valueView = (EditText) views[1];
|
||||
String key = keyView.getEditableText().toString();
|
||||
String value = valueView.getEditableText().toString();
|
||||
globalParams.put(key, value);
|
||||
sendLog("Global param added: " + key + "=" + value);
|
||||
}
|
||||
});
|
||||
|
||||
addOneButton("Clear global params", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
globalParams.clear();
|
||||
sendLog("Global params cleared.");
|
||||
}
|
||||
});
|
||||
|
||||
addFourButton(
|
||||
"IP type v4",
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
requestIpType = RequestIpType.v4;
|
||||
sendLog("Request IP type: v4");
|
||||
}
|
||||
},
|
||||
"IP type v6",
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
requestIpType = RequestIpType.v6;
|
||||
sendLog("Request IP type: v6");
|
||||
}
|
||||
},
|
||||
"IP type both",
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
requestIpType = RequestIpType.both;
|
||||
sendLog("Request IP type: both");
|
||||
}
|
||||
},
|
||||
"IP type auto",
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
requestIpType = RequestIpType.auto;
|
||||
sendLog("Request IP type: auto");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
addAutoCompleteTextViewButton(HOSTS, "Host", "Set host", new OnButtonClick() {
|
||||
@Override
|
||||
public void onBtnClick(View view) {
|
||||
AutoCompleteTextView hostView = (AutoCompleteTextView) view;
|
||||
host = hostView.getEditableText().toString();
|
||||
sendLog("Host set to: " + host);
|
||||
}
|
||||
});
|
||||
|
||||
addEditTextEditTextButton("key", "value", "Resolve with param", new OnButtonClickMoreView() {
|
||||
@Override
|
||||
public void onBtnClick(View[] views) {
|
||||
EditText keyView = (EditText) views[0];
|
||||
EditText valueView = (EditText) views[1];
|
||||
HashMap<String, String> params = new HashMap<>(globalParams);
|
||||
params.put(keyView.getEditableText().toString(), valueView.getEditableText().toString());
|
||||
HTTPDNSResult result = MyApp.getInstance().getService().getIpsByHostAsync(
|
||||
host, requestIpType, params, "sdns-demo");
|
||||
sendLog("SDNS result: " + result);
|
||||
}
|
||||
});
|
||||
|
||||
addTwoButton("Resolve scale1", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
HashMap<String, String> params = new HashMap<>(globalParams);
|
||||
params.put("scale", "scale1");
|
||||
HTTPDNSResult result = MyApp.getInstance().getService().getIpsByHostAsync(
|
||||
host, requestIpType, params, "sdns-demo");
|
||||
sendLog("scale1 result: " + result);
|
||||
}
|
||||
}, "Resolve scale2", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
HashMap<String, String> params = new HashMap<>(globalParams);
|
||||
params.put("scale", "scale2");
|
||||
HTTPDNSResult result = MyApp.getInstance().getService().getIpsByHostAsync(
|
||||
host, requestIpType, params, "sdns-demo");
|
||||
sendLog("scale2 result: " + result);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aliyun.ams.httpdns.demo;
|
||||
package com.newsdk.ams.httpdns.demo;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aliyun.ams.httpdns.demo.base;
|
||||
package com.newsdk.ams.httpdns.demo.base;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
@@ -17,8 +17,8 @@ import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.aliyun.ams.httpdns.demo.MyApp;
|
||||
import com.aliyun.ams.httpdns.demo.R;
|
||||
import com.newsdk.ams.httpdns.demo.MyApp;
|
||||
import com.newsdk.ams.httpdns.demo.R;
|
||||
|
||||
public class BaseActivity extends Activity {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aliyun.ams.httpdns.demo.http;
|
||||
package com.newsdk.ams.httpdns.demo.http;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
@@ -6,14 +6,14 @@ import android.net.SSLCertificateSocketFactory;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.HTTPDNSResult;
|
||||
import com.alibaba.sdk.android.httpdns.NetType;
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType;
|
||||
import com.alibaba.sdk.android.httpdns.SyncService;
|
||||
import com.alibaba.sdk.android.httpdns.net.HttpDnsNetworkDetector;
|
||||
import com.aliyun.ams.httpdns.demo.MyApp;
|
||||
import com.aliyun.ams.httpdns.demo.NetworkRequest;
|
||||
import com.aliyun.ams.httpdns.demo.utils.Util;
|
||||
import com.newsdk.sdk.android.httpdns.HTTPDNSResult;
|
||||
import com.newsdk.sdk.android.httpdns.NetType;
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType;
|
||||
import com.newsdk.sdk.android.httpdns.SyncService;
|
||||
import com.newsdk.sdk.android.httpdns.net.HttpDnsNetworkDetector;
|
||||
import com.newsdk.ams.httpdns.demo.MyApp;
|
||||
import com.newsdk.ams.httpdns.demo.NetworkRequest;
|
||||
import com.newsdk.ams.httpdns.demo.utils.Util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.aliyun.ams.httpdns.demo.okhttp;
|
||||
package com.newsdk.ams.httpdns.demo.okhttp;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.HTTPDNSResult;
|
||||
import com.alibaba.sdk.android.httpdns.NetType;
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType;
|
||||
import com.alibaba.sdk.android.httpdns.SyncService;
|
||||
import com.alibaba.sdk.android.httpdns.net.HttpDnsNetworkDetector;
|
||||
import com.aliyun.ams.httpdns.demo.MyApp;
|
||||
import com.aliyun.ams.httpdns.demo.NetworkRequest;
|
||||
import com.aliyun.ams.httpdns.demo.utils.Util;
|
||||
import com.newsdk.sdk.android.httpdns.HTTPDNSResult;
|
||||
import com.newsdk.sdk.android.httpdns.NetType;
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType;
|
||||
import com.newsdk.sdk.android.httpdns.SyncService;
|
||||
import com.newsdk.sdk.android.httpdns.net.HttpDnsNetworkDetector;
|
||||
import com.newsdk.ams.httpdns.demo.MyApp;
|
||||
import com.newsdk.ams.httpdns.demo.NetworkRequest;
|
||||
import com.newsdk.ams.httpdns.demo.utils.Util;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aliyun.ams.httpdns.demo.utils;
|
||||
package com.newsdk.ams.httpdns.demo.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.newsdk.ams.httpdns.demo.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.newsdk.sdk.android.httpdns.HTTPDNSResult;
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType;
|
||||
import com.newsdk.sdk.android.httpdns.SyncService;
|
||||
import com.newsdk.ams.httpdns.demo.MyApp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class ThreadUtil {
|
||||
|
||||
public static void multiThreadTest(
|
||||
final String[] validHosts,
|
||||
final int hostCount,
|
||||
final int threadCount,
|
||||
final int executeTime,
|
||||
final boolean async,
|
||||
final RequestIpType type
|
||||
) {
|
||||
new Thread(() -> runMultiThreadTest(validHosts, hostCount, threadCount, executeTime, async, type)).start();
|
||||
}
|
||||
|
||||
private static void runMultiThreadTest(
|
||||
String[] validHosts,
|
||||
int hostCount,
|
||||
int threadCount,
|
||||
int executeTime,
|
||||
boolean async,
|
||||
RequestIpType type
|
||||
) {
|
||||
int validCount = Math.min(validHosts.length, hostCount);
|
||||
Log.d(MyApp.TAG, "Start multiThreadTest, threads=" + threadCount
|
||||
+ ", executeTimeMs=" + executeTime
|
||||
+ ", hostCount=" + hostCount
|
||||
+ ", validHostCount=" + validCount
|
||||
+ ", async=" + async
|
||||
+ ", ipType=" + type.name());
|
||||
|
||||
ArrayList<String> hosts = new ArrayList<>(hostCount);
|
||||
for (int i = 0; i < hostCount - validCount; i++) {
|
||||
hosts.add("test" + i + ".Aliyun.com");
|
||||
}
|
||||
hosts.addAll(Arrays.asList(validHosts).subList(0, validCount));
|
||||
|
||||
ExecutorService pool = Executors.newFixedThreadPool(threadCount);
|
||||
CountDownLatch done = new CountDownLatch(threadCount);
|
||||
|
||||
for (int i = 0; i < threadCount; i++) {
|
||||
pool.execute(() -> {
|
||||
Random random = new Random(Thread.currentThread().getId());
|
||||
long begin = System.currentTimeMillis();
|
||||
int requestCount = 0;
|
||||
int successCount = 0;
|
||||
|
||||
while (System.currentTimeMillis() - begin < executeTime) {
|
||||
String host = hosts.get(random.nextInt(hosts.size()));
|
||||
try {
|
||||
HTTPDNSResult result;
|
||||
if (async) {
|
||||
result = MyApp.getInstance().getService().getIpsByHostAsync(host, type);
|
||||
} else {
|
||||
result = ((SyncService) MyApp.getInstance().getService()).getByHost(host, type);
|
||||
}
|
||||
if (result != null && result.getIps() != null && result.getIps().length > 0) {
|
||||
successCount++;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
Log.w(MyApp.TAG, "multiThreadTest request failed: " + t.getMessage());
|
||||
}
|
||||
requestCount++;
|
||||
}
|
||||
|
||||
Log.w(MyApp.TAG, "multiThreadTest thread=" + Thread.currentThread().getId()
|
||||
+ ", requestCount=" + requestCount
|
||||
+ ", successCount=" + successCount);
|
||||
done.countDown();
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
done.await();
|
||||
} catch (InterruptedException ignored) {
|
||||
} finally {
|
||||
pool.shutdownNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.aliyun.ams.httpdns.demo.utils;
|
||||
package com.newsdk.ams.httpdns.demo.utils;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.HTTPDNSResult;
|
||||
import com.newsdk.sdk.android.httpdns.HTTPDNSResult;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
@@ -11,7 +11,7 @@
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/aliyun_bg" />
|
||||
android:background="@drawable/new_bg" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/logScrollView"
|
||||
|
||||
@@ -1,31 +1,30 @@
|
||||
<resources>
|
||||
<string name="app_name">銆愰樋閲屼簯HttpDns銆慏emo绋嬪簭</string>
|
||||
<resources>
|
||||
<string name="app_name">閵嗘劙妯嬮柌灞肩隘HttpDns閵嗘厪emo缁嬪绨</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="normal_parse">鏅€氳В鏋?/string>
|
||||
<string name="request_taobao">瑙f瀽娣樺疂鍩熷悕</string>
|
||||
<string name="request_apple">瑙f瀽apple鍩熷悕</string>
|
||||
<string name="request_douban">瑙f瀽璞嗙摚鍩熷悕</string>
|
||||
<string name="https_parse">HTTPS寮€鍏?/string>
|
||||
<string name="timeout">璁剧疆瓒呮椂</string>
|
||||
<string name="set_expired">鍏佽杩囨湡鍩熷悕</string>
|
||||
<string name="set_cache">寮€鍚寔涔呭寲缂撳瓨</string>
|
||||
<string name="set_degration_filter">闄嶇骇绛栫暐</string>
|
||||
<string name="set_pre_resolve">棰勮В鏋?/string>
|
||||
<string name="normal_parse">閺咁噣鈧俺袙閺</string>
|
||||
<string name="request_taobao">鐟欙絾鐎藉ǎ妯虹杺閸╃喎鎮</string>
|
||||
<string name="request_apple">鐟欙絾鐎絘pple閸╃喎鎮</string>
|
||||
<string name="request_douban">鐟欙絾鐎界挒鍡欐憵閸╃喎鎮</string>
|
||||
<string name="https_parse">HTTPS瀵偓閸</string>
|
||||
<string name="timeout">鐠佸墽鐤嗙搾鍛</string>
|
||||
<string name="set_expired">閸忎浇顔忔潻鍥ㄦ埂閸╃喎鎮</string>
|
||||
<string name="set_cache">瀵偓閸氼垱瀵旀稊鍛缂傛挸鐡</string>
|
||||
<string name="set_degration_filter">闂勫秶楠囩粵鏍殣</string>
|
||||
<string name="set_pre_resolve">妫板嫯袙閺</string>
|
||||
<string name="set_region">region</string>
|
||||
<string name="sync_request">鍚屾瑙f瀽</string>
|
||||
<string name="multi_sync_request">鍚屾瑙f瀽骞跺彂</string>
|
||||
<string name="multi_request">骞跺彂瑙f瀽</string>
|
||||
<string name="sync_request">閸氬本顒炵憴锝嗙€</string>
|
||||
<string name="multi_sync_request">閸氬本顒炵憴锝嗙€介獮璺哄絺</string>
|
||||
<string name="multi_request">楠炶泛褰傜憴锝嗙€</string>
|
||||
|
||||
<string name="main_about_us">鍏充簬鎴戜滑</string>
|
||||
<string name="main_helper">甯姪涓績</string>
|
||||
<string name="main_clear_text">娓呴櫎褰撳墠娑堟伅</string>
|
||||
<string name="main_about_us">閸忓厖绨幋鎴滄粦</string>
|
||||
<string name="main_helper">鐢喖濮稉顓炵妇</string>
|
||||
<string name="main_clear_text">濞撳懘娅庤ぐ鎾冲濞戝牊浼</string>
|
||||
|
||||
<!--鍏充簬鎴戜滑椤甸潰-->
|
||||
<string name="layout_aboutus_arr">All Rights Reserved.</string>
|
||||
<string name="layout_aboutus_company">闃块噷浜?杞欢)鏈夐檺鍏徃鐗堟潈鎵€鏈?/string>
|
||||
<string name="layout_aboutus_copyright">Copyright 漏 2009 - 2016 Aliyun.com</string>
|
||||
<string name="layout_aboutus_company">闂冨潡鍣锋禍?鏉烆垯娆?閺堝妾洪崗顒€寰冮悧鍫熸綀閹碘偓閺</string>
|
||||
<string name="layout_aboutus_copyright">Copyright 婕?2009 - 2016 Aliyun.com</string>
|
||||
<string name="layout_aboutus_app_version">1.1.3</string>
|
||||
<!--甯姪涓績椤甸潰-->
|
||||
<string name="layout_helpus_content">Q : 浠€涔堟槸鐢ㄦ埛浣撻獙Demo锛焅nA : 鐢ㄦ埛浣撻獙Demo灏辨槸闃块噷浜戝钩鍙颁负鎮ㄨ嚜鍔ㄥ垱寤虹殑銆佺敤鏉ヤ綋楠孒ttpDns鏈嶅姟鍜屽弽棣堝缓璁敤鐨勪竴涓皬Demo锛岃鎮ㄤ綋楠屼究鎹枫€侀珮鏁堢殑HttpDns鏈嶅姟銆俓n\nQ : 濡備綍鑱旂郴鎴戜滑锛焅nA : App Demo鐩稿叧闂锛岃鎼滅储閽夐拤缇ゅ彿锛?1777313</string>
|
||||
<string name="layout_helpus_content">Q : 娴犫偓娑斿牊妲搁悽銊﹀煕娴f捇鐛橠emo閿涚剠nA : 閻劍鍩涙担鎾荤崣Demo鐏忚鲸妲搁梼鍧楀櫡娴滄垵閽╅崣棰佽礋閹劏鍤滈崝銊ュ灡瀵よ櫣娈戦妴浣烘暏閺夈儰缍嬫瀛抰tpDns閺堝秴濮熼崪灞藉冀妫e牆缂撶拋顔炬暏閻ㄥ嫪绔存稉顏勭毈Demo閿涘矁顔€閹劋缍嬫灞肩┒閹规灚鈧線鐝弫鍫㈡畱HttpDns閺堝秴濮熼妴淇搉\nQ : 婵″倷缍嶉懕鏃傞兇閹存垳婊戦敍鐒卬A : App Demo閻╃鍙ч梻顕€顣介敍宀冾嚞閹兼粎鍌ㄩ柦澶愭嫟缂囥倕褰块敍?1777313</string>
|
||||
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="true">
|
||||
<Alibaba-anchors>
|
||||
<New-anchors>
|
||||
<certificates src="system" />
|
||||
</Alibaba-anchors>
|
||||
</New-anchors>
|
||||
</base-config>
|
||||
</network-security-config>
|
||||
|
||||
@@ -9,11 +9,11 @@ gradle.ext {
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.aliyun.ams.httpdns.demo'
|
||||
namespace 'com.newsdk.ams.httpdns.demo'
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.aliyun.ams.httpdns.demo"
|
||||
applicationId "com.newsdk.ams.httpdns.demo"
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 34
|
||||
versionCode 1
|
||||
@@ -111,18 +111,17 @@ dependencies {
|
||||
|
||||
implementation("com.squareup.okhttp3:okhttp:4.10.0")
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
|
||||
// implementation project(path: ':httpdns-sdk')
|
||||
implementation 'com.aliyun.ams:alicloud-android-httpdns:2.6.6'
|
||||
implementation project(path: ':httpdns-sdk')
|
||||
|
||||
implementation('com.alibaba:fastjson:1.1.73.android@jar')
|
||||
implementation('com.newsdk:fastjson:1.1.73.android@jar')
|
||||
// implementation('com.emas.hybrid:emas-hybrid-android:1.1.0.4-public-SNAPSHOT') {
|
||||
// exclude group: 'com.android.support', module: 'appcompat-v7'
|
||||
// exclude group: 'com.taobao.android', module: 'thin_so_release'
|
||||
// }
|
||||
|
||||
implementation 'com.aliyun.ams:alicloud-android-tool:1.1.0'
|
||||
implementation 'com.newsdk.ams:new-android-tool:1.1.0'
|
||||
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
-keep class com.alibaba.sdk.android.httpdns.**{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.**{*;}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo
|
||||
package com.newsdk.ams.emas.demo
|
||||
|
||||
import android.support.test.InstrumentationRegistry
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
@@ -19,7 +19,7 @@ class ExampleInstrumentedTest {
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.alibaba.ams.emas.demo", appContext.packageName)
|
||||
assertEquals("com.newsdk.ams.emas.demo", appContext.packageName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<uses-permission android:name="android.permission.READ_BASIC_PHONE_STATE" />
|
||||
|
||||
<application
|
||||
android:name="com.alibaba.ams.emas.demo.HttpDnsApplication"
|
||||
android:name="com.newsdk.ams.emas.demo.HttpDnsApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
@@ -14,27 +14,27 @@
|
||||
android:roundIcon="@mipmap/ic_launcher"
|
||||
android:supportsRtl="true"
|
||||
android:extractNativeLibs="true"
|
||||
android:theme="@style/Theme.AlicloudHttpDnsDemo"
|
||||
android:theme="@style/Theme.NewHttpDnsDemo"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:name="com.alibaba.ams.emas.demo.ui.practice.HttpDnsWebviewGetActivity"
|
||||
android:name="com.newsdk.ams.emas.demo.ui.practice.HttpDnsWebviewGetActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.AlicloudHttpDnsDemo.NoActionBar">
|
||||
android:theme="@style/Theme.NewHttpDnsDemo.NoActionBar">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.alibaba.ams.emas.demo.ui.info.list.ListActivity"
|
||||
android:name="com.newsdk.ams.emas.demo.ui.info.list.ListActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.AlicloudHttpDnsDemo.NoActionBar">
|
||||
android:theme="@style/Theme.NewHttpDnsDemo.NoActionBar">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.alibaba.ams.emas.demo.MainActivity"
|
||||
android:name="com.newsdk.ams.emas.demo.MainActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
@@ -47,9 +47,9 @@
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<activity android:name="com.alibaba.ams.emas.demo.ui.info.SdnsGlobalSettingActivity"
|
||||
<activity android:name="com.newsdk.ams.emas.demo.ui.info.SdnsGlobalSettingActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.AlicloudHttpDnsDemo.NoActionBar" >
|
||||
android:theme="@style/Theme.NewHttpDnsDemo.NoActionBar" >
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo
|
||||
package com.newsdk.ams.emas.demo
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo
|
||||
package com.newsdk.ams.emas.demo
|
||||
|
||||
import android.app.Application
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.alibaba.ams.emas.demo
|
||||
package com.newsdk.ams.emas.demo
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_ENABLE_AUTH_MODE
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_SECRET_KEY_SET_BY_CONFIG
|
||||
import com.alibaba.sdk.android.httpdns.HttpDns
|
||||
import com.alibaba.sdk.android.httpdns.HttpDnsService
|
||||
import com.aliyun.ams.httpdns.demo.BuildConfig
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_ENABLE_AUTH_MODE
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_SECRET_KEY_SET_BY_CONFIG
|
||||
import com.newsdk.sdk.android.httpdns.HttpDns
|
||||
import com.newsdk.sdk.android.httpdns.HttpDnsService
|
||||
import com.newsdk.ams.httpdns.demo.BuildConfig
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo
|
||||
package com.newsdk.ams.emas.demo
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
@@ -6,8 +6,8 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.setupActionBarWithNavController
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.aliyun.ams.httpdns.demo.databinding.ActivityMainBinding
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.httpdns.demo.databinding.ActivityMainBinding
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo
|
||||
package com.newsdk.ams.emas.demo
|
||||
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo
|
||||
package com.newsdk.ams.emas.demo
|
||||
|
||||
import android.util.Log
|
||||
import androidx.annotation.MainThread
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.alibaba.ams.emas.demo
|
||||
package com.newsdk.ams.emas.demo
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.CacheTtlChanger
|
||||
import com.newsdk.sdk.android.httpdns.CacheTtlChanger
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.alibaba.ams.emas.demo
|
||||
package com.newsdk.ams.emas.demo
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.alibaba.sdk.android.httpdns.ranking.IPRankingBean
|
||||
import com.aliyun.ams.httpdns.demo.BuildConfig
|
||||
import com.newsdk.sdk.android.httpdns.ranking.IPRankingBean
|
||||
import com.newsdk.ams.httpdns.demo.BuildConfig
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
@@ -113,7 +113,7 @@ fun String?.toBlackList(): MutableList<String>? {
|
||||
|
||||
fun getAccountPreference(context: Context): SharedPreferences {
|
||||
return context.getSharedPreferences(
|
||||
"Aliyun_httpdns_${BuildConfig.ACCOUNT_ID}",
|
||||
"New_httpdns_${BuildConfig.ACCOUNT_ID}",
|
||||
Context.MODE_PRIVATE
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.constant
|
||||
package com.newsdk.ams.emas.demo.constant
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.alibaba.ams.emas.demo.net
|
||||
package com.newsdk.ams.emas.demo.net
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.alibaba.ams.emas.demo.HttpDnsServiceHolder
|
||||
import com.alibaba.ams.emas.demo.readStringFrom
|
||||
import com.alibaba.ams.emas.demo.ui.resolve.Response
|
||||
import com.alibaba.sdk.android.httpdns.HTTPDNSResult
|
||||
import com.alibaba.sdk.android.httpdns.HttpDnsCallback
|
||||
import com.alibaba.sdk.android.httpdns.NetType
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType
|
||||
import com.alibaba.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
import com.newsdk.ams.emas.demo.HttpDnsServiceHolder
|
||||
import com.newsdk.ams.emas.demo.readStringFrom
|
||||
import com.newsdk.ams.emas.demo.ui.resolve.Response
|
||||
import com.newsdk.sdk.android.httpdns.HTTPDNSResult
|
||||
import com.newsdk.sdk.android.httpdns.HttpDnsCallback
|
||||
import com.newsdk.sdk.android.httpdns.NetType
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType
|
||||
import com.newsdk.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
import java.io.BufferedReader
|
||||
import java.io.InputStream
|
||||
import java.io.InputStreamReader
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.alibaba.ams.emas.demo.net
|
||||
package com.newsdk.ams.emas.demo.net
|
||||
|
||||
import com.alibaba.ams.emas.demo.ui.resolve.Response
|
||||
import com.newsdk.ams.emas.demo.ui.resolve.Response
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.alibaba.ams.emas.demo.net
|
||||
package com.newsdk.ams.emas.demo.net
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.alibaba.ams.emas.demo.HttpDnsServiceHolder
|
||||
import com.alibaba.sdk.android.httpdns.HTTPDNSResult
|
||||
import com.alibaba.sdk.android.httpdns.HttpDnsCallback
|
||||
import com.alibaba.sdk.android.httpdns.NetType
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType
|
||||
import com.alibaba.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
import com.newsdk.ams.emas.demo.HttpDnsServiceHolder
|
||||
import com.newsdk.sdk.android.httpdns.HTTPDNSResult
|
||||
import com.newsdk.sdk.android.httpdns.HttpDnsCallback
|
||||
import com.newsdk.sdk.android.httpdns.NetType
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType
|
||||
import com.newsdk.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
import okhttp3.ConnectionPool
|
||||
import okhttp3.Dns
|
||||
import okhttp3.OkHttpClient
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.net
|
||||
package com.newsdk.ams.emas.demo.net
|
||||
|
||||
import android.util.Log
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.alibaba.ams.emas.demo.net
|
||||
package com.newsdk.ams.emas.demo.net
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.ams.emas.demo.ui.resolve.Response
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType
|
||||
import com.newsdk.ams.emas.demo.ui.resolve.Response
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.net
|
||||
package com.newsdk.ams.emas.demo.net
|
||||
|
||||
import android.net.SSLCertificateSocketFactory
|
||||
import android.os.Build
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.basic
|
||||
package com.newsdk.ams.emas.demo.ui.basic
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
@@ -11,12 +11,12 @@ import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_REGION
|
||||
import com.alibaba.ams.emas.demo.getAccountPreference
|
||||
import com.alibaba.ams.emas.demo.ui.info.list.ListActivity
|
||||
import com.alibaba.ams.emas.demo.ui.info.list.kListItemTag
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.aliyun.ams.httpdns.demo.databinding.FragmentBasicSettingBinding
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_REGION
|
||||
import com.newsdk.ams.emas.demo.getAccountPreference
|
||||
import com.newsdk.ams.emas.demo.ui.info.list.ListActivity
|
||||
import com.newsdk.ams.emas.demo.ui.info.list.kListItemTag
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.httpdns.demo.databinding.FragmentBasicSettingBinding
|
||||
|
||||
class BasicSettingFragment : Fragment(), IBasicShowDialog {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.basic
|
||||
package com.newsdk.ams.emas.demo.ui.basic
|
||||
|
||||
import android.app.Application
|
||||
import android.text.TextUtils
|
||||
@@ -6,16 +6,16 @@ import android.util.Log
|
||||
import android.widget.CompoundButton
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import com.alibaba.ams.emas.demo.*
|
||||
import com.alibaba.ams.emas.demo.constant.*
|
||||
import com.alibaba.sdk.android.httpdns.HttpDns
|
||||
import com.alibaba.sdk.android.httpdns.HttpDnsService
|
||||
import com.alibaba.sdk.android.httpdns.InitConfig
|
||||
import com.alibaba.sdk.android.httpdns.NotUseHttpDnsFilter
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType
|
||||
import com.alibaba.sdk.android.httpdns.log.HttpDnsLog
|
||||
import com.aliyun.ams.httpdns.demo.BuildConfig
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.emas.demo.*
|
||||
import com.newsdk.ams.emas.demo.constant.*
|
||||
import com.newsdk.sdk.android.httpdns.HttpDns
|
||||
import com.newsdk.sdk.android.httpdns.HttpDnsService
|
||||
import com.newsdk.sdk.android.httpdns.InitConfig
|
||||
import com.newsdk.sdk.android.httpdns.NotUseHttpDnsFilter
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType
|
||||
import com.newsdk.sdk.android.httpdns.log.HttpDnsLog
|
||||
import com.newsdk.ams.httpdns.demo.BuildConfig
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.basic
|
||||
package com.newsdk.ams.emas.demo.ui.basic
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.info
|
||||
package com.newsdk.ams.emas.demo.ui.info
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
@@ -8,9 +8,9 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.alibaba.ams.emas.demo.ui.info.list.*
|
||||
import com.aliyun.ams.httpdns.demo.BuildConfig
|
||||
import com.aliyun.ams.httpdns.demo.databinding.FragmentInfoBinding
|
||||
import com.newsdk.ams.emas.demo.ui.info.list.*
|
||||
import com.newsdk.ams.httpdns.demo.BuildConfig
|
||||
import com.newsdk.ams.httpdns.demo.databinding.FragmentInfoBinding
|
||||
|
||||
class InfoFragment : Fragment() {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.alibaba.ams.emas.demo.ui.info
|
||||
package com.newsdk.ams.emas.demo.ui.info
|
||||
|
||||
import android.app.Application
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import com.alibaba.ams.emas.demo.HttpDnsApplication
|
||||
import com.alibaba.ams.emas.demo.HttpDnsServiceHolder
|
||||
import com.alibaba.ams.emas.demo.SingleLiveData
|
||||
import com.alibaba.ams.emas.demo.getAccountPreference
|
||||
import com.alibaba.sdk.android.httpdns.NetType
|
||||
import com.alibaba.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
import com.aliyun.ams.httpdns.demo.BuildConfig
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.emas.demo.HttpDnsApplication
|
||||
import com.newsdk.ams.emas.demo.HttpDnsServiceHolder
|
||||
import com.newsdk.ams.emas.demo.SingleLiveData
|
||||
import com.newsdk.ams.emas.demo.getAccountPreference
|
||||
import com.newsdk.sdk.android.httpdns.NetType
|
||||
import com.newsdk.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
import com.newsdk.ams.httpdns.demo.BuildConfig
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
|
||||
|
||||
class InfoViewModel(application: Application) : AndroidViewModel(application) {
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.alibaba.ams.emas.demo.ui.info
|
||||
package com.newsdk.ams.emas.demo.ui.info
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_SDNS_GLOBAL_PARAMS
|
||||
import com.alibaba.ams.emas.demo.getAccountPreference
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.aliyun.ams.httpdns.demo.databinding.ActivitySdnsGlobalSettingBinding
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_SDNS_GLOBAL_PARAMS
|
||||
import com.newsdk.ams.emas.demo.getAccountPreference
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.httpdns.demo.databinding.ActivitySdnsGlobalSettingBinding
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.info.list
|
||||
package com.newsdk.ams.emas.demo.ui.info.list
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
@@ -16,8 +16,8 @@ import androidx.appcompat.widget.AppCompatEditText
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.aliyun.ams.httpdns.demo.databinding.ActivityListBinding
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.httpdns.demo.databinding.ActivityListBinding
|
||||
|
||||
class ListActivity : AppCompatActivity(), ListAdapter.OnDeleteListener {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.alibaba.ams.emas.demo.ui.info.list
|
||||
package com.newsdk.ams.emas.demo.ui.info.list
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.aliyun.ams.httpdns.demo.databinding.InfoListItemBinding;
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.httpdns.demo.databinding.InfoListItemBinding;
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.info.list
|
||||
package com.newsdk.ams.emas.demo.ui.info.list
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.info.list
|
||||
package com.newsdk.ams.emas.demo.ui.info.list
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.alibaba.ams.emas.demo.ui.info.list
|
||||
package com.newsdk.ams.emas.demo.ui.info.list
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.alibaba.ams.emas.demo.*
|
||||
import com.alibaba.ams.emas.demo.TtlCacheHolder.toJsonString
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_BATCH_RESOLVE_HOST_LIST
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_HOST_BLACK_LIST
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_HOST_WITH_FIXED_IP
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_IP_RANKING_ITEMS
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_PRE_RESOLVE_HOST_LIST
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_TAGS
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_TTL_CHANGER
|
||||
import com.alibaba.sdk.android.httpdns.ranking.IPRankingBean
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.emas.demo.*
|
||||
import com.newsdk.ams.emas.demo.TtlCacheHolder.toJsonString
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_BATCH_RESOLVE_HOST_LIST
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_HOST_BLACK_LIST
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_HOST_WITH_FIXED_IP
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_IP_RANKING_ITEMS
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_PRE_RESOLVE_HOST_LIST
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_TAGS
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_TTL_CHANGER
|
||||
import com.newsdk.sdk.android.httpdns.ranking.IPRankingBean
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import kotlinx.coroutines.launch
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.practice
|
||||
package com.newsdk.ams.emas.demo.ui.practice
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
@@ -8,8 +8,8 @@ import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.aliyun.ams.httpdns.demo.databinding.FragmentBestPracticeBinding
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.httpdns.demo.databinding.FragmentBestPracticeBinding
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.alibaba.ams.emas.demo.ui.practice
|
||||
package com.newsdk.ams.emas.demo.ui.practice
|
||||
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.alibaba.ams.emas.demo.HttpDnsServiceHolder
|
||||
import com.alibaba.ams.emas.demo.net.TLSSNISocketFactory
|
||||
import com.alibaba.ams.emas.demo.readStringFrom
|
||||
import com.alibaba.sdk.android.httpdns.NetType
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType
|
||||
import com.alibaba.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
import com.Alibaba.sdk.android.tool.NetworkUtils
|
||||
import com.newsdk.ams.emas.demo.HttpDnsServiceHolder
|
||||
import com.newsdk.ams.emas.demo.net.TLSSNISocketFactory
|
||||
import com.newsdk.ams.emas.demo.readStringFrom
|
||||
import com.newsdk.sdk.android.httpdns.NetType
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType
|
||||
import com.newsdk.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
import com.alibaba.sdk.android.tool.NetworkUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.practice
|
||||
package com.newsdk.ams.emas.demo.ui.practice
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
@@ -6,9 +6,9 @@ import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.webkit.*
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.alibaba.ams.emas.demo.HttpDnsServiceHolder
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.aliyun.ams.httpdns.demo.databinding.ActivityHttpDnsWebviewBinding
|
||||
import com.newsdk.ams.emas.demo.HttpDnsServiceHolder
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.httpdns.demo.databinding.ActivityHttpDnsWebviewBinding
|
||||
import java.io.IOException
|
||||
import java.net.*
|
||||
import javax.net.ssl.*
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.practice
|
||||
package com.newsdk.ams.emas.demo.ui.practice
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.practice
|
||||
package com.newsdk.ams.emas.demo.ui.practice
|
||||
|
||||
import android.net.SSLCertificateSocketFactory
|
||||
import java.net.InetAddress
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.resolve
|
||||
package com.newsdk.ams.emas.demo.ui.resolve
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.resolve
|
||||
package com.newsdk.ams.emas.demo.ui.resolve
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.resolve
|
||||
package com.newsdk.ams.emas.demo.ui.resolve
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
@@ -8,11 +8,11 @@ import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_RESOLVE_IP_TYPE
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_RESOLVE_METHOD
|
||||
import com.alibaba.ams.emas.demo.getAccountPreference
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.aliyun.ams.httpdns.demo.databinding.FragmentResolveBinding
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_RESOLVE_IP_TYPE
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_RESOLVE_METHOD
|
||||
import com.newsdk.ams.emas.demo.getAccountPreference
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.httpdns.demo.databinding.FragmentResolveBinding
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
|
||||
@@ -177,7 +177,7 @@ class ResolveFragment : Fragment(), IResolveShowDialog {
|
||||
val builder = activity?.let { act -> AlertDialog.Builder(act) }
|
||||
builder?.apply {
|
||||
setTitle(R.string.select_resolve_method)
|
||||
val items = arrayOf("鍚屾鏂规硶", "寮傛鏂规硶", "鍚屾闈為樆濉炴柟娉?)
|
||||
val items = arrayOf("Sync", "Async", "Sync NonBlocking")
|
||||
val preferences = activity?.let { getAccountPreference(it) }
|
||||
|
||||
var resolvedMethod = preferences?.getString(KEY_RESOLVE_METHOD, "getHttpDnsResultForHostSync(String host, RequestIpType type)").toString()
|
||||
@@ -1,20 +1,20 @@
|
||||
package com.alibaba.ams.emas.demo.ui.resolve
|
||||
package com.newsdk.ams.emas.demo.ui.resolve
|
||||
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import android.widget.RadioGroup
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.alibaba.ams.emas.demo.HttpDnsApplication
|
||||
import com.alibaba.ams.emas.demo.SingleLiveData
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_RESOLVE_IP_TYPE
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_RESOLVE_METHOD
|
||||
import com.alibaba.ams.emas.demo.constant.KEY_SDNS_RESOLVE
|
||||
import com.alibaba.ams.emas.demo.getAccountPreference
|
||||
import com.alibaba.ams.emas.demo.net.HttpURLConnectionRequest
|
||||
import com.alibaba.ams.emas.demo.net.OkHttpRequest
|
||||
import com.alibaba.sdk.android.httpdns.RequestIpType
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.emas.demo.HttpDnsApplication
|
||||
import com.newsdk.ams.emas.demo.SingleLiveData
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_RESOLVE_IP_TYPE
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_RESOLVE_METHOD
|
||||
import com.newsdk.ams.emas.demo.constant.KEY_SDNS_RESOLVE
|
||||
import com.newsdk.ams.emas.demo.getAccountPreference
|
||||
import com.newsdk.ams.emas.demo.net.HttpURLConnectionRequest
|
||||
import com.newsdk.ams.emas.demo.net.OkHttpRequest
|
||||
import com.newsdk.sdk.android.httpdns.RequestIpType
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.resolve
|
||||
package com.newsdk.ams.emas.demo.ui.resolve
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.ui.resolve
|
||||
package com.newsdk.ams.emas.demo.ui.resolve
|
||||
|
||||
/**
|
||||
* @author allen.wy
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo.widget
|
||||
package com.newsdk.ams.emas.demo.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.PointF
|
||||
@@ -9,7 +9,7 @@ import android.view.ViewConfiguration
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.Scroller
|
||||
import com.aliyun.ams.httpdns.demo.R
|
||||
import com.newsdk.ams.httpdns.demo.R
|
||||
import java.lang.ref.WeakReference
|
||||
import kotlin.math.abs
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/Theme.AlicloudHttpDnsDemo.AppBarOverlay">
|
||||
android:theme="@style/Theme.NewHttpDnsDemo.AppBarOverlay">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/webview_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/Theme.AlicloudHttpDnsDemo.PopupOverlay"
|
||||
app:popupTheme="@style/Theme.NewHttpDnsDemo.PopupOverlay"
|
||||
app:titleTextColor="@color/white"
|
||||
app:navigationIcon="@drawable/ic_back"/>
|
||||
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.alibaba.ams.emas.demo.ui.info.list.ListActivity">
|
||||
tools:context="com.newsdk.ams.emas.demo.ui.info.list.ListActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/Theme.AlicloudHttpDnsDemo.AppBarOverlay">
|
||||
android:theme="@style/Theme.NewHttpDnsDemo.AppBarOverlay">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/info_list_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/Theme.AlicloudHttpDnsDemo.PopupOverlay"
|
||||
app:popupTheme="@style/Theme.NewHttpDnsDemo.PopupOverlay"
|
||||
app:titleTextColor="@color/white"
|
||||
app:navigationIcon="@drawable/ic_back"/>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/Theme.AlicloudHttpDnsDemo.AppBarOverlay"
|
||||
android:theme="@style/Theme.NewHttpDnsDemo.AppBarOverlay"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
@@ -19,7 +19,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/Theme.AlicloudHttpDnsDemo.PopupOverlay"
|
||||
app:popupTheme="@style/Theme.NewHttpDnsDemo.PopupOverlay"
|
||||
app:titleTextColor="@color/white"
|
||||
app:navigationIcon="@drawable/ic_back"/>
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
<data>
|
||||
|
||||
<import type="com.aliyun.ams.httpdns.demo.BuildConfig" />
|
||||
<import type="com.newsdk.ams.httpdns.demo.BuildConfig" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.alibaba.ams.emas.demo.ui.basic.BasicSettingViewModel" />
|
||||
type="com.newsdk.ams.emas.demo.ui.basic.BasicSettingViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.alibaba.ams.emas.demo.ui.practice.BestPracticeViewModel" />
|
||||
type="com.newsdk.ams.emas.demo.ui.practice.BestPracticeViewModel" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
<data>
|
||||
|
||||
<import type="com.aliyun.ams.httpdns.demo.BuildConfig" />
|
||||
<import type="com.newsdk.ams.httpdns.demo.BuildConfig" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.alibaba.ams.emas.demo.ui.info.InfoViewModel" />
|
||||
type="com.newsdk.ams.emas.demo.ui.info.InfoViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
@@ -78,7 +78,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:textSize="15dp"
|
||||
tools:text="com.aliyun.ams.httpdns.demo" />
|
||||
tools:text="com.newsdk.ams.httpdns.demo" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.alibaba.ams.emas.demo.ui.resolve.ResolveViewModel" />
|
||||
type="com.newsdk.ams.emas.demo.ui.resolve.ResolveViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.alibaba.ams.emas.demo.widget.SwipeLayout
|
||||
<com.newsdk.ams.emas.demo.widget.SwipeLayout
|
||||
android:id="@+id/host_and_port_or_ttl_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -106,9 +106,9 @@
|
||||
android:textSize="17dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
</com.alibaba.ams.emas.demo.widget.SwipeLayout>
|
||||
</com.newsdk.ams.emas.demo.widget.SwipeLayout>
|
||||
|
||||
<com.alibaba.ams.emas.demo.widget.SwipeLayout
|
||||
<com.newsdk.ams.emas.demo.widget.SwipeLayout
|
||||
android:id="@+id/host_fixed_ip_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -160,6 +160,6 @@
|
||||
android:textSize="17dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
</com.alibaba.ams.emas.demo.widget.SwipeLayout>
|
||||
</com.newsdk.ams.emas.demo.widget.SwipeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -7,25 +7,25 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/navigation_basic"
|
||||
android:name="com.alibaba.ams.emas.demo.ui.basic.BasicSettingFragment"
|
||||
android:name="com.newsdk.ams.emas.demo.ui.basic.BasicSettingFragment"
|
||||
android:label="@string/title_basic"
|
||||
tools:layout="@layout/fragment_basic_setting" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/navigation_resolve"
|
||||
android:name="com.alibaba.ams.emas.demo.ui.resolve.ResolveFragment"
|
||||
android:name="com.newsdk.ams.emas.demo.ui.resolve.ResolveFragment"
|
||||
android:label="@string/title_resolve"
|
||||
tools:layout="@layout/fragment_resolve" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/navigation_best_practice"
|
||||
android:name="com.alibaba.ams.emas.demo.ui.practice.BestPracticeFragment"
|
||||
android:name="com.newsdk.ams.emas.demo.ui.practice.BestPracticeFragment"
|
||||
android:label="@string/title_best_practice"
|
||||
tools:layout="@layout/fragment_best_practice" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/navigation_information"
|
||||
android:name="com.alibaba.ams.emas.demo.ui.info.InfoFragment"
|
||||
android:name="com.newsdk.ams.emas.demo.ui.info.InfoFragment"
|
||||
android:label="@string/title_info"
|
||||
tools:layout="@layout/fragment_info" />
|
||||
</navigation>
|
||||
@@ -1,6 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Alicloudandroidsdkhttpdns_for_open_source" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<style name="Theme.Newandroidsdkhttpdns_for_open_source" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_200</item>
|
||||
<item name="colorPrimaryDark">@color/purple_700</item>
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
<string name="app_name">闃块噷浜慔ttpDNS瀹樻柟Demo</string>
|
||||
<string name="title_basic">鍩虹璁剧疆</string>
|
||||
<string name="title_resolve">HttpDNS瑙f瀽</string>
|
||||
<string name="title_best_practice">鏈€浣冲疄璺?/string>
|
||||
<string name="title_best_practice">鏈€浣冲疄璺</string>
|
||||
<string name="title_info">淇℃伅</string>
|
||||
|
||||
<string name="enable_auth_mode">寮€鍚壌鏉冩ā寮?/string>
|
||||
<string name="enable_auth_mode">寮€鍚壌鏉冩ā寮</string>
|
||||
<string name="secret_key_location">SecretKey閫氳繃config閰嶇疆</string>
|
||||
<string name="enable_encrypt_mode">寮€鍚姞瀵嗘ā寮?/string>
|
||||
<string name="enable_encrypt_mode">寮€鍚姞瀵嗘ā寮</string>
|
||||
<string name="enable_expired_ip">鍏佽杩囨湡IP</string>
|
||||
<string name="enable_local_cache">寮€鍚寔涔呭寲缂撳瓨IP</string>
|
||||
<string name="cache_expire_time">缂撳瓨杩囨湡鏃堕棿</string>
|
||||
@@ -19,11 +19,11 @@
|
||||
<string name="enable_httpdns_log">鍏佽SDK鎵撳嵃鏃ュ織</string>
|
||||
<string name="timeout">瓒呮椂鏃堕棿</string>
|
||||
<string name="init_tip">璇峰厛鍒濆鍖朒ttpDns</string>
|
||||
<string name="inited_httpdns">宸茬粡鍒濆鍖?/string>
|
||||
<string name="inited_httpdns">宸茬粡鍒濆鍖</string>
|
||||
|
||||
<string name="china">涓浗</string>
|
||||
<string name="china_hk">涓浗棣欐腐</string>
|
||||
<string name="singapore">鏂板姞鍧?/string>
|
||||
<string name="singapore">鏂板姞鍧</string>
|
||||
<string name="germany">寰峰浗</string>
|
||||
<string name="america">缇庡浗</string>
|
||||
<string name="pre">棰勫彂</string>
|
||||
@@ -31,72 +31,72 @@
|
||||
<string name="select_region">閫夋嫨Region</string>
|
||||
<string name="confirm">纭</string>
|
||||
<string name="cancel">鍙栨秷</string>
|
||||
<string name="timeout_hint">璇疯緭鍏ヨ秴鏃舵椂闂达紝姣涓哄崟浣?/string>
|
||||
<string name="timeout_hint">璇疯緭鍏ヨ秴鏃舵椂闂达紝姣涓哄崟浣</string>
|
||||
<string name="set_timeout">璁剧疆瓒呮椂</string>
|
||||
<string name="timeout_empty">瓒呮椂鏃堕棿涓虹┖</string>
|
||||
|
||||
<string name="ip_probe_list">鎺㈡祴IP鍒楄〃</string>
|
||||
<string name="ttl_cache_list">鑷畾涔塗TL缂撳瓨鍒楄〃</string>
|
||||
<string name="host_fixed_ip_list">涓荤珯鍩熷悕鍒楄〃</string>
|
||||
<string name="host_black_list">鍩熷悕榛戝悕鍗曞垪琛?/string>
|
||||
<string name="host_black_list">鍩熷悕榛戝悕鍗曞垪琛</string>
|
||||
<string name="sdns_global_params">鑷畾涔夎В鏋愬叏灞€鍙傛暟</string>
|
||||
<string name="batch_resolve">鎵归噺瑙f瀽鍩熷悕</string>
|
||||
|
||||
<string name="httpdns_sdk_version">HttpDNS鐗堟湰鍙?/string>
|
||||
<string name="httpdns_sdk_version">HttpDNS鐗堟湰鍙</string>
|
||||
<string name="unknown">鏈煡</string>
|
||||
<string name="ip_stack">褰撳墠鎵€杩炴帴缃戠粶鐨勭綉缁滄爤绫诲瀷</string>
|
||||
<string name="clear_host_cache">娓呯┖鎸囧畾鍩熷悕缂撳瓨</string>
|
||||
<string name="clear_cache_hint">璇疯緭鍏ヨ娓呯┖缂撳瓨鐨勫煙鍚?/string>
|
||||
<string name="clear_cache_hint">璇疯緭鍏ヨ娓呯┖缂撳瓨鐨勫煙鍚</string>
|
||||
<string name="network_request_type">缃戠粶璇锋眰绫诲瀷</string>
|
||||
<string name="async_resolve">寮傛瑙f瀽鑾峰彇IP</string>
|
||||
<string name="sdns_resolve">鑷畾涔夊煙鍚嶈В鏋?/string>
|
||||
<string name="sdns_resolve">鑷畾涔夊煙鍚嶈В鏋</string>
|
||||
<string name="ip_type">瑕佽В鏋愮殑IP绫诲瀷</string>
|
||||
<string name="resolve_method">浣跨敤鐨勮В鏋愭柟娉?/string>
|
||||
<string name="resolve_method">浣跨敤鐨勮В鏋愭柟娉</string>
|
||||
<string name="request_num">骞跺彂璇锋眰娆℃暟</string>
|
||||
|
||||
<string name="select_resolve_ip_type">閫夋嫨IP绫诲瀷</string>
|
||||
<string name="select_resolve_method">閫夋嫨瑙f瀽鏂规硶</string>
|
||||
<string name="select_request_num">閫夋嫨骞跺彂璇锋眰娆℃暟</string>
|
||||
<string name="auto_get_ip_type">鑷姩鍒ゆ柇IP绫诲瀷</string>
|
||||
<string name="add_pre_resolve">娣诲姞棰勮В鏋愬煙鍚?/string>
|
||||
<string name="add_pre_resolve">娣诲姞棰勮В鏋愬煙鍚</string>
|
||||
<string name="add_pre_resolve_hint">璇疯緭鍏ヨ棰勮В鏋愮殑鍩熷悕</string>
|
||||
<string name="pre_resolve_list">棰勮В鏋愬煙鍚嶅垪琛?/string>
|
||||
<string name="pre_resolve_list">棰勮В鏋愬煙鍚嶅垪琛</string>
|
||||
<string name="add_tag">娣诲姞Tag</string>
|
||||
<string name="pre_resolve_host_duplicate">%s鍩熷悕宸茬粡琚坊鍔犺嚦棰勮В鏋愬垪琛紝璇峰嬁閲嶅娣诲姞</string>
|
||||
<string name="init_httpdns">鍒濆鍖朒ttpDns</string>
|
||||
<string name="batch_resolve_list">鎵归噺瑙f瀽鍩熷悕鍒楄〃</string>
|
||||
<string name="add_batch_resolve_hint">璇疯緭鍏ヨ鎵归噺瑙f瀽鐨勫煙鍚?/string>
|
||||
<string name="add_batch_resolve">璇疯緭鍏ヨ鎵归噺瑙f瀽鐨勫煙鍚?/string>
|
||||
<string name="batch_resolve_host_duplicate">%s鍩熷悕宸茬粡琚坊鍔犺嚦鎵归噺瑙f瀽鍒楄〃锛岃鍕块噸澶嶆坊鍔?/string>
|
||||
<string name="add_batch_resolve_hint">璇疯緭鍏ヨ鎵归噺瑙f瀽鐨勫煙鍚</string>
|
||||
<string name="add_batch_resolve">璇疯緭鍏ヨ鎵归噺瑙f瀽鐨勫煙鍚</string>
|
||||
<string name="batch_resolve_host_duplicate">%s鍩熷悕宸茬粡琚坊鍔犺嚦鎵归噺瑙f瀽鍒楄〃锛岃鍕块噸澶嶆坊鍔</string>
|
||||
|
||||
<string name="host">鍩熷悕锛?/string>
|
||||
<string name="port">绔彛锛?/string>
|
||||
<string name="host">鍩熷悕锛</string>
|
||||
<string name="port">绔彛锛</string>
|
||||
<string name="ttl">TTL鏃堕暱: </string>
|
||||
|
||||
<string name="add_host_fixed_ip_hint">璇疯緭鍏ヤ富绔欏煙鍚?/string>
|
||||
<string name="add_host_fixed_ip_hint">璇疯緭鍏ヤ富绔欏煙鍚</string>
|
||||
<string name="add_host_fixed_ip">娣诲姞涓荤珯鍩熷悕</string>
|
||||
<string name="host_fixed_ip_empty">涓荤珯鍩熷悕涓虹┖</string>
|
||||
<string name="host_fixed_ip_duplicate">%s涓荤珯鍩熷悕宸茬粡琚坊鍔狅紝璇峰嬁閲嶅娣诲姞</string>
|
||||
|
||||
<string name="add_tag_hint">璇疯緭鍏ユ爣绛?/string>
|
||||
<string name="add_tag_hint">璇疯緭鍏ユ爣绛</string>
|
||||
|
||||
<string name="add_host_to_black_list_hint">璇疯緭鍏ヤ笉浣跨敤HttpDns瑙f瀽鐨勫煙鍚?/string>
|
||||
<string name="add_host_to_black_list">娣诲姞涓嶄娇鐢℉ttpDns鐨勫煙鍚?/string>
|
||||
<string name="add_host_to_black_list_hint">璇疯緭鍏ヤ笉浣跨敤HttpDns瑙f瀽鐨勫煙鍚</string>
|
||||
<string name="add_host_to_black_list">娣诲姞涓嶄娇鐢℉ttpDns鐨勫煙鍚</string>
|
||||
<string name="host_to_black_list_empty">鍩熷悕涓虹┖</string>
|
||||
<string name="host_black_list_duplicate">%s鍩熷悕宸茬粡鍦ㄩ粦鍚嶅崟涓紝璇峰嬁閲嶅娣诲姞</string>
|
||||
|
||||
<string name="add_ip_probe_host_hint">璇疯緭鍏ユ帰娴婭P鐨勫煙鍚?/string>
|
||||
<string name="add_ip_probe_port_hint">璇疯緭鍏ユ帰娴婭P鐨勭鍙?/string>
|
||||
<string name="add_ip_probe_host_hint">璇疯緭鍏ユ帰娴婭P鐨勫煙鍚</string>
|
||||
<string name="add_ip_probe_port_hint">璇疯緭鍏ユ帰娴婭P鐨勭鍙</string>
|
||||
<string name="add_ip_probe">娣诲姞IP鎺㈡祴</string>
|
||||
<string name="port_is_empty">绔彛鍙蜂负绌?/string>
|
||||
<string name="ip_probe_item_duplicate">%s:%s宸茬粡琚坊鍔犺嚦IP鎺㈡祴鍒楄〃锛岃鍕块噸澶嶆坊鍔?/string>
|
||||
<string name="port_is_empty">绔彛鍙蜂负绌</string>
|
||||
<string name="ip_probe_item_duplicate">%s:%s宸茬粡琚坊鍔犺嚦IP鎺㈡祴鍒楄〃锛岃鍕块噸澶嶆坊鍔</string>
|
||||
|
||||
<string name="host_is_empty">鍩熷悕涓虹┖</string>
|
||||
<string name="pre_resolve_host_is_empty">棰勮В鏋愮殑鍩熷悕涓虹┖</string>
|
||||
<string name="batch_resolve_host_is_empty">鎵归噺瑙f瀽鐨勫煙鍚嶄负绌?/string>
|
||||
<string name="batch_resolve_host_is_empty">鎵归噺瑙f瀽鐨勫煙鍚嶄负绌</string>
|
||||
|
||||
<string name="add_ttl_host_hint">璇疯緭鍏ョ紦瀛樼殑鍩熷悕</string>
|
||||
<string name="add_ttl_ttl_hint">璇疯緭鍏ョ紦瀛樼殑ttl鏃堕棿锛屽崟浣嶏細绉?/string>
|
||||
<string name="add_ttl_ttl_hint">璇疯緭鍏ョ紦瀛樼殑ttl鏃堕棿锛屽崟浣嶏細绉</string>
|
||||
<string name="add_custom_ttl">娣诲姞鑷畾涔塗TL</string>
|
||||
<string name="ttl_is_empty">TTL鏃堕棿涓虹┖</string>
|
||||
<string name="ttl_is_not_number">璇疯緭鍏ユ纭牸寮忕殑TTL鏃堕暱</string>
|
||||
@@ -118,13 +118,13 @@
|
||||
<string name="input_the_request_api">瑕佽姹傜殑鎺ュ彛</string>
|
||||
<string name="input_the_request_api_help_text">渚嬪: /document_detail/434554.html</string>
|
||||
|
||||
<string name="resolve_and_request">瑙f瀽骞惰姹?/string>
|
||||
<string name="resolve_and_request">瑙f瀽骞惰姹</string>
|
||||
<string name="resolve_host_empty">鍩熷悕涓嶈兘涓虹┖</string>
|
||||
<string name="host_is_ip">鍩熷悕涓嶈兘鏄疘P鍦板潃</string>
|
||||
<string name="host_illegal">璇疯緭鍏ユ纭牸寮忕殑鍩熷悕</string>
|
||||
<string name="schema_type">Schema绫诲瀷</string>
|
||||
<string name="httpdns_webview_best_practice">HttpDNS WebView 鎷︽埅GET璇锋眰</string>
|
||||
<string name="httpdns_webview_post_best_practice">HttpDNS WebView POST璇锋眰閫氳繃Native鍙戦€?/string>
|
||||
<string name="httpdns_webview_post_best_practice">HttpDNS WebView POST璇锋眰閫氳繃Native鍙戦€</string>
|
||||
<string name="httpdns_sni">HttpDNS IP鐩磋繛鏂规</string>
|
||||
|
||||
<string name="ok">濂界殑</string>
|
||||
@@ -133,6 +133,6 @@
|
||||
<string name="sni_request">IP鐩磋繛鏂规</string>
|
||||
|
||||
<string name="tips">鎻愮ず</string>
|
||||
<string name="network_not_connect">缃戠粶鏈繛鎺ワ紝璇锋鏌ョ綉缁?/string>
|
||||
<string name="network_not_connect">缃戠粶鏈繛鎺ワ紝璇锋鏌ョ綉缁</string>
|
||||
<string name="request_exception">璇锋眰寮傚父: %s</string>
|
||||
</resources>
|
||||
@@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">Alibaba Cloud HttpDNS Demo</string>
|
||||
<string name="app_name">New Cloud HttpDNS Demo</string>
|
||||
<string name="title_basic">Basic Settings</string>
|
||||
<string name="title_resolve">HttpDNS Resolve</string>
|
||||
<string name="title_best_practice">Best Practice</string>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.AlicloudHttpDnsDemo" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<style name="Theme.NewHttpDnsDemo" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/cloud_blue</item>
|
||||
<item name="colorPrimaryDark">@color/cloud_blue</item>
|
||||
@@ -9,12 +9,12 @@
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.AlicloudHttpDnsDemo.NoActionBar">
|
||||
<style name="Theme.NewHttpDnsDemo.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.AlicloudHttpDnsDemo.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
<style name="Theme.NewHttpDnsDemo.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="Theme.AlicloudHttpDnsDemo.PopupOverlay" parent="ThemeOverlay.AppCompat.Dark" />
|
||||
<style name="Theme.NewHttpDnsDemo.PopupOverlay" parent="ThemeOverlay.AppCompat.Dark" />
|
||||
</resources>
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.ams.emas.demo
|
||||
package com.newsdk.ams.emas.demo
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
@@ -12,7 +12,7 @@ android {
|
||||
targetSdkVersion 33
|
||||
versionCode 1
|
||||
versionName httpdnsDebugVersion
|
||||
setProperty("archivesBaseName", "alicloud-android-httpdns-$versionName")
|
||||
setProperty("archivesBaseName", "new-android-httpdns-$versionName")
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
buildConfigField "String", "VERSION_NAME", "\"${httpdnsDebugVersion}\""
|
||||
|
||||
@@ -89,9 +89,9 @@ dependencies {
|
||||
testEnd2endImplementation 'org.mockito:mockito-core:2.15.0'
|
||||
testEnd2endImplementation 'com.squareup.okhttp3:mockwebserver:3.9.0'
|
||||
|
||||
implementation "com.aliyun.ams:alicloud-android-logger:${loggerVersion}"
|
||||
implementation "com.aliyun.ams:alicloud-android-crashdefend:${crashDefendVersion}"
|
||||
implementation "com.aliyun.ams:alicloud-android-ipdetector:${ipdetectorVersion}"
|
||||
implementation "com.newsdk.ams:new-android-logger:${loggerVersion}"
|
||||
implementation "com.newsdk.ams:new-android-crashdefend:${crashDefendVersion}"
|
||||
implementation "com.newsdk.ams:new-android-ipdetector:${ipdetectorVersion}"
|
||||
}
|
||||
|
||||
ext.getIntlVersion = { version ->
|
||||
@@ -108,7 +108,7 @@ task copyDependencies {
|
||||
if (config != null) {
|
||||
config.resolvedConfiguration.resolvedArtifacts.each { artifact ->
|
||||
def file = artifact.file
|
||||
if (file.name.contains("alicloud-android")) {
|
||||
if (file.name.contains("new-android")) {
|
||||
copy {
|
||||
from file
|
||||
into 'build/outputs/dependencies'
|
||||
|
||||
@@ -24,27 +24,27 @@
|
||||
#-allowaccessmodification
|
||||
-useuniqueclassmembernames
|
||||
|
||||
-keeppackagenames com.alibaba.sdk.android.httpdns
|
||||
-keep class com.alibaba.sdk.android.httpdns.HttpDns{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.HttpDnsService{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.SyncService{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.RequestIpType{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.net64.Net64Service{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.DegradationFilter{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.ranking.IPRankingBean{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.ILogger{*;}
|
||||
-keepclasseswithmembers class com.alibaba.sdk.android.httpdns.log.HttpDnsLog {
|
||||
-keeppackagenames com.newsdk.sdk.android.httpdns
|
||||
-keep class com.newsdk.sdk.android.httpdns.HttpDns{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.HttpDnsService{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.SyncService{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.RequestIpType{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.net64.Net64Service{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.DegradationFilter{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.ranking.IPRankingBean{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.ILogger{*;}
|
||||
-keepclasseswithmembers class com.newsdk.sdk.android.httpdns.log.HttpDnsLog {
|
||||
public static *** setLogger(***);
|
||||
public static *** removeLogger(***);
|
||||
public static *** enable(***);
|
||||
}
|
||||
-keep class com.alibaba.sdk.android.httpdns.HTTPDNSResult{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.ApiForTest{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.test.** {*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.resolve.ResolveHostResponse{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.HTTPDNSResult{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.ApiForTest{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.test.** {*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.resolve.ResolveHostResponse{*;}
|
||||
|
||||
|
||||
-keep class com.alibaba.sdk.android.httpdns.utils.CommonUtil{
|
||||
-keep class com.newsdk.sdk.android.httpdns.utils.CommonUtil{
|
||||
public <methods>;
|
||||
public <fields>;
|
||||
}
|
||||
@@ -24,47 +24,47 @@
|
||||
#-allowaccessmodification
|
||||
-useuniqueclassmembernames
|
||||
|
||||
-dontwarn com.alibaba.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
-dontwarn com.newsdk.sdk.android.httpdns.net.HttpDnsNetworkDetector
|
||||
|
||||
-keeppackagenames com.alibaba.sdk.android.httpdns
|
||||
-flattenpackagehierarchy com.alibaba.sdk.android.httpdns
|
||||
-keep class com.alibaba.sdk.android.httpdns.HttpDns{*;}
|
||||
-keep interface com.alibaba.sdk.android.httpdns.HttpDnsService{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.impl.ErrorImpl{*;}
|
||||
-keep interface com.alibaba.sdk.android.httpdns.SyncService{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.InitConfig{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.InitConfig$Builder{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.RequestIpType{*;}
|
||||
-keep interface com.alibaba.sdk.android.httpdns.DegradationFilter{*;}
|
||||
-keep interface com.alibaba.sdk.android.httpdns.NotUseHttpDnsFilter{*;}
|
||||
-keep interface com.alibaba.sdk.android.httpdns.HttpDnsCallback{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.ranking.IPRankingBean{*;}
|
||||
-keep interface com.alibaba.sdk.android.httpdns.ILogger{*;}
|
||||
-keep interface com.alibaba.sdk.android.httpdns.CacheTtlChanger{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.NetType{*;}
|
||||
-keepclasseswithmembers class com.alibaba.sdk.android.httpdns.log.HttpDnsLog {
|
||||
-keeppackagenames com.newsdk.sdk.android.httpdns
|
||||
-flattenpackagehierarchy com.newsdk.sdk.android.httpdns
|
||||
-keep class com.newsdk.sdk.android.httpdns.HttpDns{*;}
|
||||
-keep interface com.newsdk.sdk.android.httpdns.HttpDnsService{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.impl.ErrorImpl{*;}
|
||||
-keep interface com.newsdk.sdk.android.httpdns.SyncService{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.InitConfig{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.InitConfig$Builder{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.RequestIpType{*;}
|
||||
-keep interface com.newsdk.sdk.android.httpdns.DegradationFilter{*;}
|
||||
-keep interface com.newsdk.sdk.android.httpdns.NotUseHttpDnsFilter{*;}
|
||||
-keep interface com.newsdk.sdk.android.httpdns.HttpDnsCallback{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.ranking.IPRankingBean{*;}
|
||||
-keep interface com.newsdk.sdk.android.httpdns.ILogger{*;}
|
||||
-keep interface com.newsdk.sdk.android.httpdns.CacheTtlChanger{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.NetType{*;}
|
||||
-keepclasseswithmembers class com.newsdk.sdk.android.httpdns.log.HttpDnsLog {
|
||||
public static *** setLogger(***);
|
||||
public static *** removeLogger(***);
|
||||
public static *** enable(***);
|
||||
}
|
||||
-keep class com.alibaba.sdk.android.httpdns.HTTPDNSResult{*;}
|
||||
-keepclasseswithmembers class com.alibaba.sdk.android.httpdns.HttpDnsSettings {
|
||||
-keep class com.newsdk.sdk.android.httpdns.HTTPDNSResult{*;}
|
||||
-keepclasseswithmembers class com.newsdk.sdk.android.httpdns.HttpDnsSettings {
|
||||
public static *** setDailyReport(***);
|
||||
public static *** setNetworkChecker(***);
|
||||
}
|
||||
|
||||
-keep class com.alibaba.sdk.android.httpdns.net.HttpDnsNetworkDetector {
|
||||
-keep class com.newsdk.sdk.android.httpdns.net.HttpDnsNetworkDetector {
|
||||
public <methods>;
|
||||
public <fields>;
|
||||
}
|
||||
|
||||
-keep class com.alibaba.sdk.android.httpdns.network.**{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.network.**{*;}
|
||||
|
||||
-keep interface com.alibaba.sdk.android.httpdns.HttpDnsSettings$NetworkChecker{*;}
|
||||
-keep interface com.alibaba.sdk.android.httpdns.HttpDnsSettings$NetworkDetector{*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.utils.CommonUtil{
|
||||
-keep interface com.newsdk.sdk.android.httpdns.HttpDnsSettings$NetworkChecker{*;}
|
||||
-keep interface com.newsdk.sdk.android.httpdns.HttpDnsSettings$NetworkDetector{*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.utils.CommonUtil{
|
||||
public <methods>;
|
||||
public <fields>;
|
||||
}
|
||||
-keep enum com.alibaba.sdk.android.httpdns.Region {*;}
|
||||
-keep class com.alibaba.sdk.android.httpdns.exception.InitException{*;}
|
||||
-keep enum com.newsdk.sdk.android.httpdns.Region {*;}
|
||||
-keep class com.newsdk.sdk.android.httpdns.exception.InitException{*;}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.alibaba.sdk.android.httpdns;
|
||||
package com.newsdk.sdk.android.httpdns;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.ranking.IPRankingTask;
|
||||
import com.newsdk.sdk.android.httpdns.ranking.IPRankingTask;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.sdk.android.httpdns;
|
||||
package com.newsdk.sdk.android.httpdns;
|
||||
|
||||
/**
|
||||
* 娴嬭瘯鐢ㄧ殑鍒濆鍖栨帴鍙?
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.alibaba.sdk.android.httpdns;
|
||||
package com.newsdk.sdk.android.httpdns;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.impl.HttpDnsInstanceHolder;
|
||||
import com.alibaba.sdk.android.httpdns.impl.InstanceCreator;
|
||||
import com.alibaba.sdk.android.httpdns.net.NetworkStateManager;
|
||||
import com.alibaba.sdk.android.httpdns.network.HttpDnsAdapterOptions;
|
||||
import com.alibaba.sdk.android.httpdns.network.HttpDnsHttpAdapter;
|
||||
import com.alibaba.sdk.android.httpdns.utils.CommonUtil;
|
||||
import com.newsdk.sdk.android.httpdns.impl.HttpDnsInstanceHolder;
|
||||
import com.newsdk.sdk.android.httpdns.impl.InstanceCreator;
|
||||
import com.newsdk.sdk.android.httpdns.net.NetworkStateManager;
|
||||
import com.newsdk.sdk.android.httpdns.network.HttpDnsAdapterOptions;
|
||||
import com.newsdk.sdk.android.httpdns.network.HttpDnsHttpAdapter;
|
||||
import com.newsdk.sdk.android.httpdns.utils.CommonUtil;
|
||||
|
||||
/**
|
||||
* Httpdns瀹炰緥绠$悊
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.sdk.android.httpdns;
|
||||
package com.newsdk.sdk.android.httpdns;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.alibaba.sdk.android.httpdns.impl;
|
||||
package com.newsdk.sdk.android.httpdns.impl;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.ApiForTest;
|
||||
import com.alibaba.sdk.android.httpdns.BeforeHttpDnsServiceInit;
|
||||
import com.alibaba.sdk.android.httpdns.HttpDnsSettings;
|
||||
import com.alibaba.sdk.android.httpdns.InitManager;
|
||||
import com.alibaba.sdk.android.httpdns.ranking.IPRankingTask;
|
||||
import com.newsdk.sdk.android.httpdns.ApiForTest;
|
||||
import com.newsdk.sdk.android.httpdns.BeforeHttpDnsServiceInit;
|
||||
import com.newsdk.sdk.android.httpdns.HttpDnsSettings;
|
||||
import com.newsdk.sdk.android.httpdns.InitManager;
|
||||
import com.newsdk.sdk.android.httpdns.ranking.IPRankingTask;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.alibaba.sdk.android.httpdns.impl;
|
||||
package com.newsdk.sdk.android.httpdns.impl;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.HttpDnsService;
|
||||
import com.newsdk.sdk.android.httpdns.HttpDnsService;
|
||||
|
||||
/**
|
||||
* 鏀逛负浣跨敤娴嬭瘯瀹炰緥
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.alibaba.sdk.android.httpdns;
|
||||
package com.newsdk.sdk.android.httpdns;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.impl.HttpDnsInstanceHolder;
|
||||
import com.alibaba.sdk.android.httpdns.impl.InstanceCreator;
|
||||
import com.alibaba.sdk.android.httpdns.network.HttpDnsAdapterOptions;
|
||||
import com.alibaba.sdk.android.httpdns.network.HttpDnsHttpAdapter;
|
||||
import com.alibaba.sdk.android.httpdns.utils.CommonUtil;
|
||||
import com.newsdk.sdk.android.httpdns.impl.HttpDnsInstanceHolder;
|
||||
import com.newsdk.sdk.android.httpdns.impl.InstanceCreator;
|
||||
import com.newsdk.sdk.android.httpdns.network.HttpDnsAdapterOptions;
|
||||
import com.newsdk.sdk.android.httpdns.network.HttpDnsHttpAdapter;
|
||||
import com.newsdk.sdk.android.httpdns.utils.CommonUtil;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.alibaba.sdk.android.httpdns.impl;
|
||||
package com.newsdk.sdk.android.httpdns.impl;
|
||||
|
||||
import com.alibaba.sdk.android.httpdns.HttpDnsService;
|
||||
import com.newsdk.sdk.android.httpdns.HttpDnsService;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.alibaba.sdk.android.httpdns.impl;
|
||||
package com.newsdk.sdk.android.httpdns.impl;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user