1 package com.netease.nimlib.sdk;
3 import android.util.Pair;
4 import androidx.annotation.Nullable;
9 import java.io.Serializable;
10 import java.util.ArrayList;
11 import java.util.Arrays;
12 import java.util.HashSet;
13 import java.util.List;
15 import org.json.JSONException;
16 import org.json.JSONObject;
24 public static final String
KEY_LBS =
"KEY_LBS";
37 public static final String
KEY_TEST =
"KEY_TEST";
224 JSONObject
object =
new JSONObject();
226 object.putOpt(KEY_MODULE, module);
227 object.putOpt(KEY_PUBLIC_KEY_VERSION, publicKeyVersion);
228 object.putOpt(KEY_LBS, lbs);
229 object.putOpt(KEY_LBS_BACKUP, CollectionUtil.toString(lbsBackup,
";"));
230 object.putOpt(KEY_DEFAULT_LINK, defaultLink);
231 object.putOpt(KEY_DEFAULT_LINK_BACKUP, CollectionUtil.toString(defaultLinkBackup,
";"));
232 object.putOpt(KEY_NOS_UPLOAD_LBS, nosUploadLbs);
233 object.putOpt(KEY_NOS_UPLOAD_DEFAULT_LINK, nosUploadDefaultLink);
234 object.putOpt(KEY_NOS_UPLOAD, nosUpload);
235 object.putOpt(KEY_NOS_SUPPORT_HTTPS, nosSupportHttps);
236 object.putOpt(KEY_NOS_DOWNLOAD_URL_FORMAT, nosDownloadUrlFormat);
237 object.putOpt(KEY_NOS_DOWNLOAD, nosDownload);
238 object.putOpt(KEY_NOS_ACCESS, nosAccess);
239 object.putOpt(KEY_NT_SERVER_ADDRESS, ntServerAddress);
240 object.putOpt(KEY_BD_SERVER_ADDRESS, bdServerAddress);
241 object.putOpt(KEY_TEST, test);
242 object.putOpt(KEY_DEDICATED_CLUSTE_FLAG, dedicatedClusteFlag);
243 object.putOpt(KEY_NEGO_KEY_NECA, negoKeyNeca == null ? AsymmetricType.RSA.getValue(): negoKeyNeca.getValue());
244 object.putOpt(KEY_NEGO_KEY_ENCA_KEY_VERSION, negoKeyEncaKeyVersion);
245 object.putOpt(KEY_NEGO_KEY_ENCA_KEY_PARTA, negoKeyEncaKeyParta);
246 object.putOpt(KEY_NEGO_KEY_ENCA_KEY_PARTB, negoKeyEncaKeyPartb);
247 object.putOpt(KEY_COMM_ENCA, commEnca == null ? SymmetryType.RC4.getValue() : commEnca.getValue());
248 object.putOpt(KEY_LINK_IPV6, linkIpv6);
249 object.putOpt(KEY_IP_PROTOCOL_VERSION, ipProtocolVersion == null ? IPVersion.IPV4.getValue() :ipProtocolVersion.getValue());
250 object.putOpt(KEY_PROBE_IPV4_URL, probeIpv4Url);
251 object.putOpt(KEY_PROBE_IPV6_URL, probeIpv6Url);
253 object.putOpt(KEY_NOS_CDN_ENABLE, nosCdnEnable);
254 object.putOpt(KEY_NOS_DOWNLOAD_SET, CollectionUtil.toString(nosDownloadSet,
";"));
255 object.putOpt(KEY_COMPASS_DATA_ENDPOINT, compassDataEndpoint);
256 }
catch (JSONException e) {
263 if (
object == null) {
268 serverAddresses.
module =
object.optString(KEY_MODULE);
270 serverAddresses.
lbs =
object.optString(KEY_LBS);
271 serverAddresses.
lbsBackup =
new ArrayList<>(Arrays.asList(
object.optString(KEY_LBS_BACKUP).split(
";")));
272 serverAddresses.
defaultLink =
object.optString(KEY_DEFAULT_LINK);
273 serverAddresses.
defaultLinkBackup =
new ArrayList<>(Arrays.asList(
object.optString(KEY_DEFAULT_LINK_BACKUP).split(
";")));
274 serverAddresses.
nosUploadLbs =
object.optString(KEY_NOS_UPLOAD_LBS);
276 serverAddresses.
nosUpload =
object.optString(KEY_NOS_UPLOAD);
277 serverAddresses.
nosSupportHttps =
object.optBoolean(KEY_NOS_SUPPORT_HTTPS);
279 serverAddresses.
nosDownload =
object.optString(KEY_NOS_DOWNLOAD);
280 serverAddresses.
nosAccess =
object.optString(KEY_NOS_ACCESS);
281 serverAddresses.
ntServerAddress =
object.optString(KEY_NT_SERVER_ADDRESS);
282 serverAddresses.
bdServerAddress =
object.optString(KEY_BD_SERVER_ADDRESS);
283 serverAddresses.
test =
object.optBoolean(KEY_TEST);
285 serverAddresses.
negoKeyNeca = AsymmetricType.value(
object.optInt(KEY_NEGO_KEY_NECA));
289 serverAddresses.
commEnca = SymmetryType.value(
object.optInt(KEY_COMM_ENCA));
290 serverAddresses.
linkIpv6 =
object.optString(KEY_LINK_IPV6);
291 serverAddresses.
ipProtocolVersion = IPVersion.value(
object.optInt(KEY_IP_PROTOCOL_VERSION));
292 serverAddresses.
probeIpv4Url =
object.optString(KEY_PROBE_IPV4_URL);
293 serverAddresses.
probeIpv6Url =
object.optString(KEY_PROBE_IPV6_URL);
295 serverAddresses.
nosCdnEnable =
object.optBoolean(KEY_NOS_CDN_ENABLE);
296 serverAddresses.
nosDownloadSet =
new HashSet<>(Arrays.asList(
object.optString(KEY_NOS_DOWNLOAD_SET).split(
";")));
298 return serverAddresses;
int negoKeyEncaKeyVersion
"交换密钥"协议加密算法密钥版本 version 自定义时则必填
String ntServerAddress
云信运行时异常统计服务器地址
static final String KEY_NOS_DOWNLOAD_SET
static final String KEY_COMPASS_DATA_ENDPOINT
static final String KEY_NOS_DOWNLOAD_URL_FORMAT
NimHandshakeType handshakeType
握手协议选择字段
String nosDownloadUrlFormat
[4.6.0版本新增] NOS下载地址拼接模板,用于拼接最终得到的下载地址。 默认是 {bucket}.nosdn.127.net/{object},SDK 上传资源后生成的下载地址为 https://bucket.nosdn.127.net/object
static final String KEY_NOS_SUPPORT_HTTPS
static final String KEY_NT_SERVER_ADDRESS
String negoKeyEncaKeyPartb
"交换密钥"协议加密算法密钥 part B 自定义时则必填 BigNumHex string 不含0x RSA: EXP, SM2: Y
static final String KEY_TEST
String lbs
IM LBS服务器地址,通过它获取IM link 地址信息 填http/https地址
int dedicatedClusteFlag
是否为专属集群{1(是), 0(否)}
static final String KEY_LBS
static final String KEY_NOS_CDN_ENABLE
static final String KEY_NOS_DOWNLOAD
static final String KEY_NOS_ACCESS
String nosDownload
NOS下载地址的host,用于拼接最终获得的文件URL地址,也支持该host替换成下载加速域名/地址 nosAccess...
IPVersion ipProtocolVersion
IP协议版本{0(IPV4), 1(IPV6), 2(Auto, SDK测试后自行选择, 存在性能损耗)}。 默认: 0(IPV4) 非对称加密 ...
static final String KEY_MODULE
static final String KEY_NEGO_KEY_NECA
static ServerAddresses fromJson(@Nullable JSONObject object)
static final String KEY_LBS_BACKUP
static final String KEY_COMM_ENCA
static final String KEY_NOS_UPLOAD_DEFAULT_LINK
Set< String > nosDownloadSet
每个元素为使用过的NOS下载地址的特征以及桶名是否在host中组成的Pair对象 如new Pair("nim.nos.netease.com", true), new Pair("nos.netease.com/nim", false)等
AsymmetricType negoKeyNeca
"交换密钥"协议加密算法 {1(RSA),2(SM2)}, def:1(RSA) 非对称加密
String nosAccess
NOS下载加速域名/地址,用于替换NOS下载url中的 nosDownload。 提供两种方式: 1) [4.4.0+开始支持]模板方式:填写云信规定的两种模板:{bucket}.nosdn.127.net/{object} 或者 nosdn.127.net/{bucket}/{object},其中 {bucket} 和 {object} 作为标识符,必须填写。域名部分可以替换为您申请的加速域名。 2) [所有版本支持]非模板方式:填写用于加速的 http/https地址,例如:http://111.222.111.22:9090
String module
连接云信服务器加密数据通道的公钥参数1 rsaModulus
static final String KEY_IP_PROTOCOL_VERSION
static final String KEY_HANDSHAKE_TYPE
static final String KEY_DEFAULT_LINK
static final String KEY_DEFAULT_LINK_BACKUP
String nosUploadDefaultLink
NOS上传默认的link服务器地址,当NOS LBS不可用时先连接该地址 填http/https地址
static final String KEY_NEGO_KEY_ENCA_KEY_PARTB
boolean nosCdnEnable
是否优先使用Cdn域名进行NOS下载
String compassDataEndpoint
数据上报端点
static final String KEY_LINK_IPV6
String probeIpv6Url
探测ipv6地址类型使用的url, IPProtVersion == 2或3 时生效
String probeIpv4Url
探测ipv4地址类型使用的url, IPProtVersion == 2或3 时生效
SymmetryType commEnca
通信加密算法 {1(RC4), 2(AES128), 4(SM4)} 默认: 1(RC4) 对称加密
String negoKeyEncaKeyParta
"交换密钥"协议加密算法密钥 part A 自定义时则必填 BigNumHex string 不含0x RSA: module, SM2: X
String nosUpload
NOS上传服务器主机地址(仅nosSupportHttps=true时有效,用作https上传时的域名校验及http header host字段...
static final String KEY_PROBE_IPV6_URL
List< String > defaultLinkBackup
IM 默认的link服务器地址不可用时,连接这些地址 填"IP/Host:PORT"
static final String KEY_DEDICATED_CLUSTE_FLAG
static final String KEY_NEGO_KEY_ENCA_KEY_VERSION
String nosUploadLbs
NOS上传LBS服务器地址 填http/https地址
String bdServerAddress
云信数据统计服务器地址
static final String KEY_PROBE_IPV4_URL
String linkIpv6
ipv6的缺省连接地址
int publicKeyVersion
连接云信服务器加密数据通道的公钥的版本号(默认0)
static final String KEY_PUBLIC_KEY_VERSION
static final String KEY_NOS_UPLOAD
static final String KEY_BD_SERVER_ADDRESS
static final String KEY_NOS_UPLOAD_LBS
String defaultLink
IM 默认的link服务器地址,当IM LBS不可用时先连接该地址 填"IP/Host:PORT"
static final String KEY_NEGO_KEY_ENCA_KEY_PARTA
List< String > lbsBackup
备用IM LBS服务器地址,通过它获取IM link 地址信息 填http/https地址
boolean nosSupportHttps
NOS上传是否需要支持https。SDK 3.2版本后默认支持https,同时需要配置 nosUpload!