AppStore上架过程记录(三)--socket-ipv6

2018年4月26日


收到苹果的邮件:

Hello,


Thank you for providing this information.


Upon further review, we found that your app does not comply with the following guidelines:


Guideline 2.1 - Performance - App Completeness


We discovered one or more bugs in your app when reviewed on iPad running iOS 11.3.1 on Wi-Fi connected to an IPv6 network.


Specifically, the 游客登录 button was unresponsive when we tapped on it.


Please see attached screenshots for details.


Next Steps


To resolve this issue, please run your app on a device to identify any issues, then revise and resubmit your app for review.


If we misunderstood the intended behavior of your app, please reply to this message in Resolution Center to provide information on how these features were intended to work.


For new apps, uninstall all previous versions of your app from a device, then install and follow the steps to reproduce the issue. For updates, install the new version as an update to the previous version, then follow the steps to reproduce the issue.


Resources


For information about testing your app and preparing it for review, please see Technical Note TN2431: App Testing Guide. 


For a networking overview, please review About Networking. For a more specific overview of App Review’s IPv6 requirements, please review the IPv6 and App Review discussion on the Apple Developer Forum.


While your iTunes Connect Application State shows as Metadata Rejected, we still require a new binary to correct this issue.


Best regards,


App Store Review

大意就是 app不支持ipv6。

1.应用登录的时候使用的是cocos2dx-3.10 自带的http库,查了下可能这个版本的cocos的libcurl和websock库不支持ipv6.

解决方法:
Cocos2d 从3.11版本开始才更新了libcurl库.因此下载了最新版本的cocos2d-3.16,将新版本的libcurl.a拷贝到3.10中的对应路径下。
这里需要注意下:
新版本的libssl.a和libcrypto.a在openssl路径下,也要拷贝过来,放到3.10版本的 curl目录下,否则会编译报错.

2.运行后,发现使用这个库的http访问时没问题的;但是底层socket调用不好使,也就是说我使用了原生的socket接口做通信,不支持ipv6.

解决方法:
官方提供了一个ipv4转换ipv6的方法,稍作修改,放到工程里面引用,代码如下。

头文件:

//
//  ipv6Nat.hpp
//  GameBase-mobile
//
//  Created by Evilstar on 2018/4/27.
//
#ifndef ipv6Nat_hpp
#define ipv6Nat_hpp
#include <stdio.h>
#include "MLNetDefine.h"
#include "Game/FV/FvSingleton.h"
class ipv6Nat
:public FvSingleton<ipv6Nat>
,public cocos2d::Ref
{
public:
    ipv6Nat();
    ~ipv6Nat();
public:
    int safeConnectIpv4(const char *ipv4_str, unsigned short port);
    
    int safeConnAgain();
private:
    struct addrinfo _addr;
    SOCKET _fd;
};
#endif /* ipv6Nat_hpp */

cpp文件:

//
//  ipv6Nat.cpp
//  GameBase-mobile
//
//  Created by Evilstar on 2018/4/27.
//
#include "ipv6Nat.hpp"
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <err.h>
FV_SINGLETON_STORAGE(ipv6Nat);
ipv6Nat::ipv6Nat()
:_fd(0)
{
    memset(&_addr,0,sizeof(struct addrinfo));
}
ipv6Nat::~ipv6Nat()
{
    
}
int ipv6Nat::safeConnectIpv4(const char *ipv4_str, unsigned short port)
{
    //uint8_t ipv4[4] = {192, 0, 2, 1};
    struct addrinfo hints,*res,*res0;
    int error, s;
    const char *cause = NULL;
    char temp[16];
    sprintf(temp,"%d",port); 
    std::string strPort = temp;
    
    //char ipv4_str_buf[INET_ADDRSTRLEN] = { 0 };
    //const char *ipv4_str = inet_ntop(AF_INET, &ipv4, ipv4_str_buf, sizeof(ipv4_str_buf));
    memset(&hints, 0, sizeof(hints));
    hints.ai_family = PF_UNSPEC;   //返回操作系统支持的协议族
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = AI_DEFAULT;
    error = getaddrinfo(ipv4_str, strPort.c_str(), &hints, &res0);
    if (error) {
        cocos2d::log("getaddrinfo error: %s",gai_strerror(error));
        //errx(1, "%s", gai_strerror(error));
        /*NOTREACHED*/
    }
    s = -1;
    for (res = res0; res; res = res->ai_next) {
        s = socket(res->ai_family, res->ai_socktype,
                   res->ai_protocol);
        cocos2d::log("family: ipv%d",res->ai_family);
        
        if (s < 0) {
            cause = "socket";
            continue;
        }
        if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
            cause = "connect";
            close(s);
            s = -1;
            continue;
        }
        break;  /* okay we got one */
        
    }
    if (s < 0) {
        cocos2d::log("socket %s error!",cause);
        //err(1, "%s", cause); //crash
        /*NOTREACHED*/
        return INVALID_SOCKET;
    }
    
    memcpy(&_addr,res,sizeof(struct addrinfo));
    _fd = s;
    
    freeaddrinfo(res0);
    
    return s;
}
int ipv6Nat::safeConnAgain()
{
    if (connect(_fd, _addr.ai_addr, _addr.ai_addrlen) < 0) {
        return -1;  //外层释放
    }
    return 0;
}

经过3天的折腾,本地测试通过了。
4月30日重新打包(version1.0.2,build版本为1.0.22)提交.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员柒叔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值