Changeset 285a41


Ignore:
Timestamp:
07/12/07 10:31:29 (6 years ago)
Author:
Erik Ekman <yarrick@…>
Branches:
master
Children:
f932e5
Parents:
861da5
git-author:
Erik Ekman <yarrick@…> (07/12/07 10:31:29)
git-committer:
Erik Ekman <erik@…> (02/04/12 20:33:55)
Message:

#16 Do case preservation check after login

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r60e00a r285a41  
    1313        - Fixed bug denying access if relay uses varying source ports 
    1414        - All received error messages (RCODE field) are echoed 
     15        - Top domain limited to 128 chars 
     16        - Case preservation check sent after login to decide codec 
    1517 
    16182007-03-25: 0.4.0 "Run Home" 
  • src/iodine.c

    r861da5 r285a41  
    5050        const char *topdomain, struct encoder *encoder); 
    5151 
    52 int running = 1; 
    53 char password[33]; 
    54  
    55 struct sockaddr_in peer; 
     52static int running = 1; 
     53static char password[33]; 
     54 
     55static struct sockaddr_in peer; 
    5656static char *topdomain; 
    5757 
    58 uint16_t rand_seed; 
     58static uint16_t rand_seed; 
    5959 
    6060/* Current IP packet */ 
    6161static struct packet packet; 
     62 
     63/* My userid at the server */ 
    6264static char userid; 
     65 
     66/* DNS id for next packet */ 
    6367static uint16_t chunkid; 
    6468 
    6569/* Base32 encoder used for non-data packets */ 
    6670static struct encoder *b32; 
     71 
    6772/* The encoder used for data packets 
    6873 * Defaults to Base32, can be changed after handshake */ 
    6974static struct encoder *dataenc; 
     75 
     76/* result of case preservation check done after login */ 
     77static int case_preserved; 
    7078 
    7179static void 
     
    350358} 
    351359 
     360void 
     361send_case_check(int fd) 
     362{ 
     363        char buf[512] = "zZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY123-4560789."; 
     364 
     365        strcat(buf, topdomain); 
     366        send_query(fd, buf); 
     367} 
     368 
    352369static int 
    353370handshake(int dns_fd) 
     
    387404                        if (read >= 9) { 
    388405                                payload =  (((in[4] & 0xff) << 24) | 
    389                                                         ((in[5] & 0xff) << 16) | 
    390                                                         ((in[6] & 0xff) << 8) | 
    391                                                         ((in[7] & 0xff))); 
     406                                                ((in[5] & 0xff) << 16) | 
     407                                                ((in[6] & 0xff) << 8) | 
     408                                                ((in[7] & 0xff))); 
    392409 
    393410                                if (strncmp("VACK", in, 4) == 0) { 
     
    447464                                        if (tun_setip(client) == 0 &&  
    448465                                                tun_setmtu(mtu) == 0) { 
    449                                                 return 0; 
     466                                                goto perform_case_check; 
    450467                                        } else { 
    451468                                                warnx("Received handshake with bad data"); 
     
    459476                printf("Retrying login...\n"); 
    460477        } 
    461  
    462         return 1; 
    463 } 
    464  
    465 static void  
     478        errx(1, "couldn't login to server"); 
     479        /* NOTREACHED */ 
     480 
     481perform_case_check: 
     482        case_preserved = 0; 
     483        for (i=0; running && i<5 ;i++) { 
     484                tv.tv_sec = i + 1; 
     485                tv.tv_usec = 0; 
     486 
     487                send_case_check(dns_fd); 
     488                 
     489                FD_ZERO(&fds); 
     490                FD_SET(dns_fd, &fds); 
     491 
     492                r = select(dns_fd + 1, &fds, NULL, NULL, &tv); 
     493 
     494                if(r > 0) { 
     495                        read = read_dns(dns_fd, in, sizeof(in)); 
     496                         
     497                        if(read <= 0) { 
     498                                warn("read"); 
     499                                continue; 
     500                        } 
     501 
     502                        if (read > 0) { 
     503                                if (in[0] == 'z' || in[0] == 'Z') { 
     504                                        if (read < (26 * 2)) { 
     505                                                printf("Received short case reply...\n"); 
     506                                        } else { 
     507                                                int k; 
     508 
     509                                                case_preserved = 1; 
     510                                                for (k = 0; k < 26 && case_preserved; k += 2) { 
     511                                                        if (in[k] == in[k+1]) { 
     512                                                                /* test string: zZaAbBcCdD... */ 
     513                                                                case_preserved = 0; 
     514                                                        } 
     515                                                } 
     516                                                return 0; 
     517                                        } 
     518                                } else { 
     519                                        printf("Received bad case check reply\n"); 
     520                                } 
     521                        } 
     522                } 
     523 
     524                printf("Retrying case check...\n"); 
     525        } 
     526 
     527        printf("No reply on case check, continuing\n"); 
     528        return 0; 
     529} 
     530 
     531static void 
    466532set_target(const char *host)  
    467533{ 
  • src/iodined.c

    r861da5 r285a41  
    237237                        users[userid].last_pkt = time(NULL); 
    238238                } 
     239        } else if(in[0] == 'Z' || in[0] == 'z') { 
     240                /* Case conservation check */ 
     241 
     242                /* Reply with received hostname as data */ 
     243                write_dns(dns_fd, &(dummy.q), in, read); 
     244                return 0; 
    239245        } else if((in[0] >= '0' && in[0] <= '9') 
    240246                        || (in[0] >= 'a' && in[0] <= 'f') 
  • src/version.h

    rdbfecb r285a41  
    2020/* This is the version of the network protocol 
    2121   It is usually equal to the latest iodine version number */ 
    22 #define VERSION 0x00000401 
     22#define VERSION 0x00000402 
    2323 
    2424#endif /* _VERSION_H_ */ 
Note: See TracChangeset for help on using the changeset viewer.