Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 2.46 KB

王一夫-20180726.md

File metadata and controls

40 lines (30 loc) · 2.46 KB

leecode

public class Solution {
    public int LengthOfLongestSubstring(string s) {
        int maxCount = 0;
        int curIndex;
        Dictionary<char, int> indexDict = new Dictionary<char, int>();
        for (int i = 0; i < s.Length; i++) {
            if (indexDict.TryGetValue(s[i], out curIndex)) {
                if (i - curIndex > maxCount) {
                    maxCount = i - curIndex;
                }
            }
            indexDict[s[i]] = i;
        }
        if (maxCount == 0) {
            maxCount = s.Length;
        }
        return maxCount;
    }
}

IPv6

IPv6(Internate Protocal version 6)是 IP 协议的最新版本,用于取代 IPv4。

从 2012 年 6 月 6 号开始,世界各大网站和网络服务供应商启用了 IPv6。从 2016 年 6月 1 日起,苹果开始强制要求 iOS App 必须兼容 IPv6-Only,而截至 2017 年 7 月,通过 IPv6 访问 Google 服务的用户百分比首次超过了 20%,这个从 1998 年就出台的协议渐渐开始履行自己的历史使命。

IPv6 采用 128 位地址,以 16 位为一组,每组以冒号 「:」 进行分割,分为 8 组。以本地 127.0.0.1 的 IPv6 地址 0000:0000:0000:0000:0000:ffff:7f00:0001 为例,可以进行省略:

  1. 每一组前导数字为 0 时,可以进行省略:0:0:0:0:0:ffff:7f00:1
  2. 当有一组或多组 0 连续出现时,可以进行省略:::ffff:7f00:1 ,但只能出现一次,例如 0:0:ffff:0:0:0:0:1 不可省略为 ::ffff::1,正确的方式是,::ffff:0:0:0:0:1 或者 0:0:ffff::1

说回 App Store IPv6-Only 的要求,他需要 App 能够在 IPv6 DNS64/NAT64 的环境里也能够正常运行,如果你的 App 使用的是域名解析,那么这一层对开发者来说基本是透明的。但是如果采用 IP 的方式则要注意,在 wiki 中描述为 「::ffff:x.x.x.x/96 用于 IPv4 映射」,假如你的 IP 地址为 8.8.8.8,则映射为 ::ffff:8.8.8.8,这在 App Store IPv6-Only 中是错误的映射方式,应该映射为 2001:2:0:1baa:ffff.8.8.8.8。因为 IPv6 DNS64/NAT64 的默认 DNS Server 路由前缀为 2001:2:0:1baa:ffff.8.8.8.8

IPv6-Only 解释 和 macOS NAT64 开启