Quellcode durchsuchen

Added & Adjusted some features (#580)

PtrKR vor 7 Jahren
Ursprung
Commit
233213df7c

+ 24 - 5
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>daum.net</li>
                 </ul>
                 '''
 
@@ -4640,5 +4659,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>;
- }
-}

+ 27 - 11
emergency_tool.py

@@ -7,8 +7,15 @@ 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)
+set_data = json.loads(data)
 
 conn = sqlite3.connect(set_data['db'] + '.db', check_same_thread = False)
 curs = conn.cursor()
@@ -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 - 42
readme-ko.md

@@ -15,48 +15,7 @@ opennamu
  * [기타](#기타)
 
 # 시작하기
-오픈나무는 파이썬 환경에서 동작하는 파이썬 애플리케이션으로, 파이썬 환경을 필요로 합니다.
-
-## 환경 구성
-### 파이썬 설치
-[파이썬 설치 가이드](https://github.com/404-sdok/how-to-python/blob/master/0.md)를 참고하여 파이썬을 설치합니다.
-
-### 릴리즈 다운로드
-[릴리즈](https://github.com/2du/openNAMU/releases)에서 opennamu의 릴리즈 판을 다운로드 받고, 압축을 해제합니다. 레포지토리를 클론하여 릴리즈를 적용하는 것도 가능합니다. 자세한 내용은 [클론](#클론)문단을 참고하세요.
-
-### 모듈 설치
-다음 명령어로 opennamu 구성 파일이 위치한 디렉토리로 이동합니다.
-```
-cd [path]
-```
-
-
-다음 명령어로 opennamu 실행에 필요한 모듈을 설치합니다.
-```
-pip install -r requirements.txt
-```
-리눅스 환경의 경우 다음 명령으로 실행해야 합니다.
-```
-pip3 install -r requirements.txt
-```
-## 애플리케이션 시작
-### 애플리케이션 시작
-opennamu를 시작합니다.
-```
-python app.py
-```
-리눅스 환경의 경우 다음 명령으로 실행해야 합니다.
-```
-python3 app.py
-```
-
-* opennamu의 첫 계정은 소유자 계정으로 설정됩니다.
-
-### 애플리케이션 공개
-현재 opennamu에서 권장하는 애플리케이션 공개 방법은 아파치나 nginx와 같은 웹서버 호스팅 소프트웨어를 통해 리버스 프록시를 설정하는 것입니다.
-
-* ([apache 설정 파일 예시](./conf_example/apache/), [nginx 설정 파일 예시](./conf_example/nginx.conf))
-
+ * 오픈나무 위키에 명시되어 있습니다. [참조](http://namu.ml/w/오픈나무%2F설치법)
 
 # 클론
 아래 명령을 터미널(명령 프롬프트)에 입력하여 본 리포지토리를 클론할 수 있습니다.