Victor's Blog

Live as if you were to die tomorrow. Learn as if you were to live forever

NAVIGATION - SEARCH

Port Blocking for Firefox and Chrome

Yesterday, I set up a testing website on my testing server with port 6000. I tried to browse it with Firefox. I got an error like "This address is restricted. This address uses a network port which is normally used for purposes other than Web browsing. Firefox has cancelled the request for your protection. " Then I tried in the Chrome, I got similar error message too. Surprisingly, IE worked fine. This was totally new to me. Then I found out the fact that Mozilla blocks some ports for the security reason. Here is a list of port they blocked :

Port Service

1 - tcpmux 7 - echo 9 - discard 11 - systat
13 - daytime 15 - netstat 17 - qotd 19 - chargen
20 - ftp data 21 - ftp control 22 - ssh 23 - telnet
25 - smtp 37 - time 42 - name 43 - nicname
53 - domain 77 - priv-rjs 79 - finger 87 - ttylink
95 - supdup 101 - hostriame 102 - iso-tsap 103 - gppitnp
104 - acr-nema 109 - POP2 110 - POP3 111 - sunrpc
113 - auth 115 - sftp 117 - uucp-path 119 - NNTP
123 - NTP 135 - loc-srv / epmap 139 - netbios 143 - IMAP2
179 - BGP 389 - LDAP 465 - SMTP+SSL 512 - print / exec
513 - login 514 - shell 515 - printer 526 - tempo
530 - courier 531 - chat 532 - netnews 540 - uucp
556 - remotefs 563 - NNTP+SSL 587 - submission 601 - syslog
636 - LDAP+SSL 993 - IMAP+SSL 995 - POP3+SSL 2049 - nfs
4045 - lockd 6000 - X11    

For more detail about this you can visit Mozilla's website.

Resolution:

1. If you can decide how to host your website, try to avoid use these ports when you config your website.

2. If you are end user, you can change your configuration to override this setting.

For Firefox, enter about:config in the address bar, and then right-click anywhere in the lower portion of the resulting page and select New and then String from the context menu. The name you need to enter is network.security.ports.banned.override, and the value is the port(s) you want to open. If you have more than one, enter them as a comma-separated list. Or you can just type "1-65535", that will open all ports.

 

How to trim the datetime in c#?

Last week I need to write something to compare two datetime at the second level. So I have to trim the datetime part after second. There is the function I used to trim the datetime. 

 

public static DateTime TrimDate(DateTime date, long ticks)
{
    return new DateTime(date.Ticks - date.Ticks % ticks);
}

Examples about how to use the function

DateTime datNewDate = TrimDate(oldDate, TimeSpan.TicksPerSecond); 

Easy!