Просмотр исходного кода

Merge pull request #580 from 2du/set-improve

여러 가지 기능 추가 및 수정
Surplus_UP (2DU) 7 лет назад
Родитель
Сommit
2132f84b16

+ 32 - 8
app.py

@@ -15,7 +15,7 @@ import random
 
 from func import *
 
-r_ver = 'v3.0.8-stable-99'
+r_ver = 'v3.0.8-master-100'
 c_ver = ''.join(re.findall('[0-9]', r_ver))
 
 print('version : ' + r_ver)
@@ -172,6 +172,25 @@ if not os.path.exists('image'):
 if not os.path.exists('views'):
     os.makedirs('views')
 
+if os.getenv('NAMU_HOST') != None:
+    rep_host = os.getenv('NAMU_HOST')
+else:
+    curs.execute('select data from other where name = "host"')
+    rep_data = curs.fetchall()
+    if not rep_data:
+        while 1:
+            print('host [0.0.0.0] : ', end = '')
+            rep_host = input()
+            if rep_host:
+                curs.execute('insert into other (name, data) values ("host", ?)', [rep_host])
+                break
+            else:
+                pass
+    else:
+        rep_host = rep_data[0][0]
+    
+        print('host : ' + str(rep_host))
+
 if os.getenv('NAMU_PORT') != None:
     rep_port = os.getenv('NAMU_PORT')
 else:
@@ -180,11 +199,9 @@ else:
     if not rep_data:
         while 1:
             print('port : ', end = '')
-        
             rep_port = int(input())
             if rep_port:
                 curs.execute('insert into other (name, data) values ("port", ?)', [rep_port])
-    
                 break
             else:
                 pass
@@ -208,7 +225,7 @@ try:
 
             curs.execute('insert into other (name, data) values ("robot", "User-agent: *\nDisallow: /\nAllow: /$\nAllow: /w/")')
         
-        print('robots.txt create')
+        print('robots.txt have created')
 except:
     pass
 
@@ -302,6 +319,7 @@ if back_time != 0:
 else:
     print('back up state : turn off')
 
+print('\n------ daemon started ------')
 conn.commit()
 
 @app.route('/del_alarm')
@@ -358,6 +376,7 @@ def inter_wiki(tools = None):
                     <li>naver.com</li>
                     <li>daum.net</li>
                     <li>hanmail.net</li>
+                    <li>hanmail2.net</li>
                 </ul>
                 '''
 
@@ -540,8 +559,8 @@ def setting(num = 0):
             menu = [['manager', load_lang('admin')]]
         ))
     elif num == 1:
-        i_list = ['name', 'logo', 'frontpage', 'license', 'upload', 'skin', 'edit', 'reg', 'ip_view', 'back_up', 'port', 'key', 'update', 'email_have', 'discussion', 'encode']
-        n_list = ['wiki', '', 'FrontPage', 'CC 0', '2', '', 'normal', '', '', '0', '3000', 'test', 'stable', '', 'normal', 'sha256']
+        i_list = ['name', 'logo', 'frontpage', 'license', 'upload', 'skin', 'edit', 'reg', 'ip_view', 'back_up', 'port', 'key', 'update', 'email_have', 'discussion', 'encode', 'host']
+        n_list = ['wiki', '', 'FrontPage', 'CC 0', '2', '', 'normal', '', '', '0', '3000', 'test', 'stable', '', 'normal', 'sha256', '0.0.0.0']
         
         if flask.request.method == 'POST':
             i = 0
@@ -674,6 +693,11 @@ def setting(num = 0):
                             <hr class=\"main_hr\">
                             <input type="checkbox" name="email_have" ''' + ch_3 + '''> must have email {<a href="/setting/5">must set google imap</a>}
                             <hr class=\"main_hr\">
+                            <span>''' + load_lang('host') + '''</span>
+                            <br>
+                            <br>
+                            <input placeholder="''' + load_lang('host') + '''" type="text" name="host" value="''' + html.escape(d_list[16]) + '''">
+                            <hr class=\"main_hr\">
                             <span>''' + load_lang('port') + '''</span>
                             <br>
                             <br>
@@ -3339,7 +3363,7 @@ def need_email(tool = 'pass_find'):
     if flask.request.method == 'POST':
         if tool == 'need_email':
             if 'c_id' in flask.session:
-                main_email = ['naver.com', 'gmail.com', 'daum.net', 'hanmail.net']
+                main_email = ['naver.com', 'gmail.com', 'daum.net', 'hanmail.net', 'hanmail2.net']
                 data = re.search('@([^@]+)$', flask.request.form.get('email', ''))
                 if data:
                     data = data.groups()[0]
@@ -4640,5 +4664,5 @@ def error_404(e):
 if __name__=="__main__":
     app.secret_key = rep_key
     http_server = tornado.httpserver.HTTPServer(tornado.wsgi.WSGIContainer(app))
-    http_server.listen(rep_port)
+    http_server.listen(rep_port, address=rep_host)
     tornado.ioloop.IOLoop.instance().start()

+ 0 - 12
conf_example/apache/httpd-vhost.conf

@@ -1,12 +0,0 @@
-<VirtualHost *:80>
-    DocumentRoot <doc root>
-    ServerName <hostname>
-    ErrorLog <errlog path>
-    CustomLog <customlog path> common
-    
-    ProxyRequests           Off
-    ProxyPreserveHost       On      
-    
-    ProxyPass           http://localhost:<port>
-    ProxyPassReverse    http://localhost:<port>
-</VirtualHost> 

+ 0 - 3
conf_example/apache/httpd.conf

@@ -1,3 +0,0 @@
-LoadModule proxy_module modules/mod_proxy.so
-LoadModule proxy_connect_module modules/mod_proxy_connect.so
-LoadModule proxy_http_module modules/mod_proxy_http.so

+ 0 - 18
conf_example/nginx.conf

@@ -1,18 +0,0 @@
-server {
- listen 80;
- listen [::]:80;
-
- listen 443 ssl;
- listen [::]:443 ssl;
-
- server_name <domain>;
-
- location / {
- proxy_redirect off;
- proxy_pass_header Server;
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Scheme $scheme;
- proxy_pass http://localhost:<port>;
- }
-}

+ 26 - 10
emergency_tool.py

@@ -7,6 +7,13 @@ import threading
 from func import *
 from mark import load_conn2, namumark
 
+try:
+    f = open('set.json', 'r')
+except:
+    print('Error: set.json not found. please run setup script first.')
+    exit()
+else:
+    f.close()
 json_data = open('set.json').read()
 set_data = json.loads(json_data)
 
@@ -18,10 +25,11 @@ load_conn(conn)
 print('1. backlink reset')
 print('2. recaptcha delete')
 print('3. ban delete')
-print('4. change port')
-print('5. change skin')
-print('6. change password')
-print('7. reset version')
+print('4. change host')
+print('5. change port')
+print('6. change skin')
+print('7. change password')
+print('8. reset version')
 
 print('select : ', end = '')
 what_i_do = input()
@@ -61,20 +69,26 @@ elif what_i_do == '3':
         curs.execute("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, ?)", [user_data, load_lang('release', 1), get_time(), load_lang('tool', 1) + ':emergency', '', band])
     curs.execute("delete from ban where block = ?", [user_data])
 elif what_i_do == '4':
+    print('host : ', end = '')
+    host = input()
+
+    curs.execute("update other set data = ? where name = 'host'", [host])
+elif what_i_do == '5':
     print('port : ', end = '')
-    port = input()
+    port = int(input())
 
     curs.execute("update other set data = ? where name = 'port'", [port])
-elif what_i_do == '5':
+elif what_i_do == '6':
     print('skin name : ', end = '')
     skin = input()
 
     curs.execute("update other set data = ? where name = 'skin'", [skin])
-elif what_i_do == '6':
+elif what_i_do == '7':
     print('1. sha256')
-    print('2. bcrypt')
+    print('2. sha3')
+    print('3. bcrypt')
     print('select : ', end = '')
-    what_i_do = input()
+    what_i_do = int(input())
 
     print('user name : ', end = '')
     user_name = input()
@@ -85,10 +99,12 @@ elif what_i_do == '6':
     if what_i_do == '1':
         hashed = hashlib.sha256(bytes(user_pw, 'utf-8')).hexdigest()
     elif what_i_do == '2':
+        hashed = sha3.sha3_256(bytes(user_pw, 'utf-8')).hexdigest()
+    elif what_i_do == '3':
         hashed = bcrypt.hashpw(bytes(user_pw, 'utf-8'), bcrypt.gensalt()).decode()
        
     curs.execute("update user set pw = ? where id = ?", [hashed, user_name])
-elif what_i_do == '7':
+elif what_i_do == '8':
     curs.execute("update other set data = '00000' where name = 'ver'")
 
 conn.commit()

+ 1 - 0
language/en-US.json

@@ -10,6 +10,7 @@
     "backup_interval" : "backup interval",
     "default" : "default",
     "language" : "language",
+    "host" : "host",
     "port" : "port",
     "secret_key" : "secret key",
     "update_branch" : "update branch",

+ 1 - 0
language/ko-KR.json

@@ -138,6 +138,7 @@
     "max_file_size" : "최대 파일 크기",
     "backup_interval" : "백업 간격",
     "default" : "기본",
+    "host" : "호스트",
     "port" : "포트",
     "secret_key" : "비밀키",
     "update_branch" : "업데이트 브랜치",

+ 1 - 1
readme-ko.md

@@ -98,4 +98,4 @@ python3 app.py
 
 [테스트 서버](http://namu.ml/)
 
-첫 번째 가입자에게 소유자 권한이 부여됩니다.
+첫 번째 가입자에게 소유자 권한이 부여됩니다.