Changeset 33 in chevmsgr


Ignore:
Timestamp:
12/09/15 06:47:21 (8 years ago)
Author:
cheese
Message:
  1. 클라이언트 UI ID/PW 입력 안하면 죽는 문제 수정
  2. UI 종료 함수 exit로 수정
  3. 그룹챗 인덱스 변수 형 때문에 나오는 warning 수정
  4. toOpenSession 함수 가끔 죽는 문제 수정
  5. generateRandom()에서 time()하던거 rand()로 수정
  6. sms 전송 url 및 sms 코드 생성 로직 대폭 수정 (주석 참고)
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/msg.hpp

    r31 r33  
    175175static cf::bin generateRandom()
    176176{
    177     int t = (int)time(NULL);
     177    srand((unsigned int)time(NULL));
     178    int t = rand();
    178179
    179180    cf::bin b;
  • trunk/msgclnt.cpp

    r32 r33  
    8989    SOpenSession o;
    9090
    91     o.sessid = message.get<std::string>(ProtocolType::SESSION_ID);
    92     o.idList = message.getList<std::string>(ProtocolType::ID_LIST);
    93 
    9491    if (message.mObject.HasKey(ProtocolType::SESSION_KEY))
    9592    {
     93        o.sessid = message.get<std::string>(ProtocolType::SESSION_ID);
     94        o.idList = message.getList<std::string>(ProtocolType::ID_LIST);
     95
    9696        std::string encodedKey = message.get<std::string>(ProtocolType::SESSION_KEY);
    9797        cf::bin key = cf::codec::hex::getInstance()->decode(encodedKey);
  • trunk/msgsrv.cpp

    r31 r33  
    294294}
    295295
    296 static unsigned int generateSeed()
    297 {
    298     unsigned int ret = 0;
    299     int t = (int)time(NULL);
    300 
    301     cf::bin b;
    302     b.resize(sizeof(int));
    303 
    304     b.set((cf::uint8_t*)&t, sizeof(int));
    305     cf::bin s = crypto().sha256(b);
    306 
    307     memcpy(&ret, s.buffer(), sizeof(unsigned int));
    308 
    309     return ret;
    310 }
    311 
    312296static std::string generateSMSCode()
    313297{
    314     return "545454";
    315     char random[8] = {0x00,};
    316     sprintf(random, "%06d", generateSeed() % 1000000);
    317 
    318     return random;
     298    cf::bin random  = generateRandom(); // ·£´ý °ª °¡Á®¿È
     299    cf::bin hash    = crypto().sha256(random); // ·£´ý °ª Çؽ¬
     300    std::string enc = cf::codec::hex::getInstance()->encode(hash); // Çؽ¬ÇÑ °á°ú hex encode
     301
     302    std::string sms; // ÃÖÁ¾ sms¹ÞÀ» º¯¼ö
     303
     304    // xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx
     305    for (int i = 0; i < 8 ; i++)
     306    {
     307        char buf[128] = {0,};
     308
     309        // [0] ºÎÅÍ 4±ÛÀÚ, [4] ºÎÅÍ 4±ÛÀÚ, ...
     310        size_t start = i * 4;
     311
     312        // 1. enc º¯¼ö¿¡¼­ 4ÀÚ¸®¾¿ ¼ø¼­´ë·Î ¶¼¾î³»¼­ xxxx- ·Î ¸¸µë
     313        //    std::string::substr(½ÃÀÛ À妽º, °³¼ö)
     314        // 2. std::string::substr() ´Â std::stringÀ» return ÇϹǷÎ,
     315        //    std::string::c_str() ÇÏ¿© const char * ÇüÀ¸·Î ¹Þ¾Æ¿È
     316        snprintf(buf, sizeof(buf), "%s-", enc.substr(start, 4).c_str());
     317
     318        // xxxx- ·Î ¸¸µç°Å sms °á°ú¿¡ Ãß°¡
     319        sms += buf;
     320    }
     321
     322    // ·çÇÁ¿¡¼­ xxxx- ¸¦ °è¼Ó ºÙ¿©¼­ ´Ù ¸¸µé°í ³ª¸é ¸¶Áö¸·ÀÌ '-' ·Î ³¡³ª°Ô µÇ¹Ç·Î ¸¶Áö¸· ±ÛÀÚ ¶¼¾î³¿
     323    sms[sms.length() - 1] = 0;
     324
     325    return sms;
    319326}
    320327
     
    325332#define CRLF    "\r\n"
    326333    std::string code = generateSMSCode();
    327     std::string url = "unsigned.kr";
    328     std::string uri = "/~cheese/sms/req.php?to=" + phone + "&code=" + code;
     334    std::string url = "chev.unsigned.kr";
     335    std::string uri = "/sms/req.php?to=" + phone + "&code=" + code;
    329336    std::string http =
    330337        "GET " + uri + " HTTP/1.1" CRLF
  • trunk/msvc14/ChevMsgrClient_MFC/AddGroupChat.cpp

    r30 r33  
    4141
    4242    for (size_t iter = 0; iter < mMsgrClntDlg->idList.size(); iter++)
    43         mFriendListToChat.InsertString(iter, str2cstr(mMsgrClntDlg->idList[iter].id));
     43        mFriendListToChat.InsertString((int)iter, str2cstr(mMsgrClntDlg->idList[iter].id));
    4444
    4545    return TRUE;
  • trunk/msvc14/ChevMsgrClient_MFC/ChevMsgrClient_MFCDlg.cpp

    r32 r33  
    136136    {
    137137        AfxMessageBox(_T("¼­¹ö Á¤º¸ ÆÄÀÏÀ» ãÀ» ¼ö ¾øÀ½"));
    138         ::SendMessage(GetSafeHwnd(), WM_QUIT, NULL, NULL);
     138        exit(1);
    139139    }
    140140    std::string ip;
     
    147147    {
    148148        AfxMessageBox(str2cstr(chev.getLastError()));
    149         ::SendMessage(GetSafeHwnd(), WM_QUIT, NULL, NULL);
     149        exit(1);
    150150    }
    151151
     
    155155    {
    156156        AfxMessageBox(_T("login failed"));
    157         ::SendMessage(GetSafeHwnd(), WM_QUIT, NULL, NULL);
     157        exit(1);
    158158    }
    159159
     
    243243                SensitiveCtrl sc;
    244244
    245                 sc.sensitiveIdx = gDlg->scl[idx].chatList.size();
     245                sc.sensitiveIdx = (int)gDlg->scl[idx].chatList.size();
    246246                sc.timestamp = (int)time(NULL);
    247247                gDlg->scl[idx].sensitiveCtrl.push_back(sc);
     
    341341            SensitiveCtrl sc;
    342342
    343             sc.sensitiveIdx = gDlg->scl[idx].chatList.size();
     343            sc.sensitiveIdx = (int)gDlg->scl[idx].chatList.size();
    344344            sc.timestamp = (int)time(NULL);
    345345            gDlg->scl[idx].sensitiveCtrl.push_back(sc);
  • trunk/msvc14/ChevMsgrClient_MFC/LoginDlg.cpp

    r31 r33  
    5959
    6060    GetDlgItemText(IDC_EDIT_LOGIN_ID, id);
     61    if (id == _T(""))
     62    {
     63        AfxMessageBox(_T("No ID"));
     64        return;
     65    }
     66
    6167    std::string name = cf::codec::hex::getInstance()->encode(c.sha256(cf::bin(cstr2str(id))));
    6268    std::ifstream f(name);
     
    7076
    7177    GetDlgItemText(IDC_EDIT_LOGIN_PW, pw);
     78    if (pw == _T(""))
     79    {
     80        AfxMessageBox(_T("No Password"));
     81        return;
     82    }
     83
    7284    f >> str;
    7385
Note: See TracChangeset for help on using the changeset viewer.