first commit, base server
This commit is contained in:
		
						commit
						e5078b4969
					
				
							
								
								
									
										29
									
								
								ServidorTFG.pro
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								ServidorTFG.pro
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| TEMPLATE = app | ||||
| CONFIG += console c++11 | ||||
| CONFIG -= app_bundle | ||||
| CONFIG -= qt | ||||
| LIBS += -lcrypto -lssl -pthread -lcppunit -lmysqlcppconn | ||||
| SOURCES += \ | ||||
|         main.cpp \ | ||||
|     conexion.cpp \ | ||||
|     conexion_ssl.cpp \ | ||||
|     thread_selector.cpp \ | ||||
|     config_reader.cpp \ | ||||
|     tests.cpp \ | ||||
|     data_acces.cpp \ | ||||
|     msql_acces.cpp \ | ||||
|     session_manager.cpp \ | ||||
|     session_manager_ssl.cpp \ | ||||
|     config_package.cpp | ||||
| 
 | ||||
| HEADERS += \ | ||||
|     conexion.h \ | ||||
|     conexion_ssl.h \ | ||||
|     thread_selector.h \ | ||||
|     config_reader.h \ | ||||
|     tests.h \ | ||||
|     data_acces.h \ | ||||
|     msql_acces.h \ | ||||
|     session_manager.h \ | ||||
|     session_manager_ssl.h \ | ||||
|     config_package.h | ||||
							
								
								
									
										292
									
								
								ServidorTFG.pro.user
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										292
									
								
								ServidorTFG.pro.user
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,292 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!DOCTYPE QtCreatorProject> | ||||
| <!-- Written by QtCreator 4.8.2, 2020-05-07T01:43:45. --> | ||||
| <qtcreator> | ||||
|  <data> | ||||
|   <variable>EnvironmentId</variable> | ||||
|   <value type="QByteArray">{6372de0b-6c3f-4b3a-9367-dde6c2574520}</value> | ||||
|  </data> | ||||
|  <data> | ||||
|   <variable>ProjectExplorer.Project.ActiveTarget</variable> | ||||
|   <value type="int">0</value> | ||||
|  </data> | ||||
|  <data> | ||||
|   <variable>ProjectExplorer.Project.EditorSettings</variable> | ||||
|   <valuemap type="QVariantMap"> | ||||
|    <value type="bool" key="EditorConfiguration.AutoIndent">true</value> | ||||
|    <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> | ||||
|    <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value> | ||||
|    <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> | ||||
|     <value type="QString" key="language">Cpp</value> | ||||
|     <valuemap type="QVariantMap" key="value"> | ||||
|      <value type="QByteArray" key="CurrentPreferences">CppGlobal</value> | ||||
|     </valuemap> | ||||
|    </valuemap> | ||||
|    <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> | ||||
|     <value type="QString" key="language">QmlJS</value> | ||||
|     <valuemap type="QVariantMap" key="value"> | ||||
|      <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value> | ||||
|     </valuemap> | ||||
|    </valuemap> | ||||
|    <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value> | ||||
|    <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value> | ||||
|    <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> | ||||
|    <value type="int" key="EditorConfiguration.IndentSize">4</value> | ||||
|    <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value> | ||||
|    <value type="int" key="EditorConfiguration.MarginColumn">80</value> | ||||
|    <value type="bool" key="EditorConfiguration.MouseHiding">true</value> | ||||
|    <value type="bool" key="EditorConfiguration.MouseNavigation">true</value> | ||||
|    <value type="int" key="EditorConfiguration.PaddingMode">1</value> | ||||
|    <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> | ||||
|    <value type="bool" key="EditorConfiguration.ShowMargin">false</value> | ||||
|    <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> | ||||
|    <value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value> | ||||
|    <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> | ||||
|    <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> | ||||
|    <value type="int" key="EditorConfiguration.TabSize">8</value> | ||||
|    <value type="bool" key="EditorConfiguration.UseGlobal">true</value> | ||||
|    <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> | ||||
|    <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> | ||||
|    <value type="bool" key="EditorConfiguration.cleanIndentation">true</value> | ||||
|    <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> | ||||
|    <value type="bool" key="EditorConfiguration.inEntireDocument">false</value> | ||||
|   </valuemap> | ||||
|  </data> | ||||
|  <data> | ||||
|   <variable>ProjectExplorer.Project.PluginSettings</variable> | ||||
|   <valuemap type="QVariantMap"> | ||||
|    <valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/> | ||||
|    <value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value> | ||||
|   </valuemap> | ||||
|  </data> | ||||
|  <data> | ||||
|   <variable>ProjectExplorer.Project.Target.0</variable> | ||||
|   <valuemap type="QVariantMap"> | ||||
|    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value> | ||||
|    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value> | ||||
|    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{dd182432-2a2f-4b92-8ddc-d07764586196}</value> | ||||
|    <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> | ||||
|    <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> | ||||
|    <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> | ||||
|    <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> | ||||
|     <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/roche/Cosas/C++/build-ServidorTFG-Desktop-Debug</value> | ||||
|     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> | ||||
|      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> | ||||
|       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value> | ||||
|       <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value> | ||||
|      </valuemap> | ||||
|      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> | ||||
|       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> | ||||
|       <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value> | ||||
|      </valuemap> | ||||
|      <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> | ||||
|     </valuemap> | ||||
|     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> | ||||
|      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> | ||||
|       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> | ||||
|       <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value> | ||||
|      </valuemap> | ||||
|      <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> | ||||
|     </valuemap> | ||||
|     <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> | ||||
|     <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> | ||||
|     <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> | ||||
|     <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value> | ||||
|     <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> | ||||
|    </valuemap> | ||||
|    <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> | ||||
|     <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/roche/Cosas/C++/build-ServidorTFG-Desktop-Release</value> | ||||
|     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> | ||||
|      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> | ||||
|       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> | ||||
|       <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value> | ||||
|      </valuemap> | ||||
|      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> | ||||
|       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> | ||||
|       <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value> | ||||
|      </valuemap> | ||||
|      <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> | ||||
|     </valuemap> | ||||
|     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> | ||||
|      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> | ||||
|       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> | ||||
|       <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value> | ||||
|      </valuemap> | ||||
|      <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> | ||||
|     </valuemap> | ||||
|     <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> | ||||
|     <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> | ||||
|     <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> | ||||
|     <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> | ||||
|     <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> | ||||
|    </valuemap> | ||||
|    <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> | ||||
|     <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/roche/Cosas/C++/build-ServidorTFG-Desktop-Profile</value> | ||||
|     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> | ||||
|      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> | ||||
|       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value> | ||||
|       <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value> | ||||
|       <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value> | ||||
|      </valuemap> | ||||
|      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> | ||||
|       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> | ||||
|       <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value> | ||||
|      </valuemap> | ||||
|      <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> | ||||
|     </valuemap> | ||||
|     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> | ||||
|      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> | ||||
|       <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|       <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> | ||||
|       <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> | ||||
|       <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> | ||||
|       <value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value> | ||||
|      </valuemap> | ||||
|      <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> | ||||
|     </valuemap> | ||||
|     <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> | ||||
|     <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> | ||||
|     <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> | ||||
|     <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> | ||||
|     <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> | ||||
|    </valuemap> | ||||
|    <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value> | ||||
|    <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> | ||||
|     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> | ||||
|      <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> | ||||
|     </valuemap> | ||||
|     <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy Configuration</value> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> | ||||
|    </valuemap> | ||||
|    <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> | ||||
|    <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/> | ||||
|    <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> | ||||
|     <value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value> | ||||
|     <value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value> | ||||
|     <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value> | ||||
|     <value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value> | ||||
|     <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value> | ||||
|     <value type="int" key="PE.EnvironmentAspect.Base">2</value> | ||||
|     <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">ServidorTFG</value> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | ||||
|     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/roche/Cosas/C++/ServidorTFG/ServidorTFG.pro</value> | ||||
|     <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">ServidorTFG.pro</value> | ||||
|     <value type="QString" key="RunConfiguration.Arguments"></value> | ||||
|     <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> | ||||
|     <value type="bool" key="RunConfiguration.UseCppDebugger">false</value> | ||||
|     <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> | ||||
|     <value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value> | ||||
|     <value type="bool" key="RunConfiguration.UseMultiProcess">false</value> | ||||
|     <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> | ||||
|     <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> | ||||
|     <value type="QString" key="RunConfiguration.WorkingDirectory"></value> | ||||
|     <value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/roche/Cosas/C++/build-ServidorTFG-Desktop-Debug</value> | ||||
|    </valuemap> | ||||
|    <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> | ||||
|   </valuemap> | ||||
|  </data> | ||||
|  <data> | ||||
|   <variable>ProjectExplorer.Project.TargetCount</variable> | ||||
|   <value type="int">1</value> | ||||
|  </data> | ||||
|  <data> | ||||
|   <variable>ProjectExplorer.Project.Updater.FileVersion</variable> | ||||
|   <value type="int">20</value> | ||||
|  </data> | ||||
|  <data> | ||||
|   <variable>Version</variable> | ||||
|   <value type="int">20</value> | ||||
|  </data> | ||||
| </qtcreator> | ||||
							
								
								
									
										82
									
								
								conexion.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								conexion.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,82 @@ | ||||
| #include "conexion.h" | ||||
| #include "session_manager.h" | ||||
| #include "msql_acces.h" | ||||
| 
 | ||||
| #include <arpa/inet.h> | ||||
| #include <thread> | ||||
| #include <unistd.h> | ||||
| 
 | ||||
| void conexion_client(int client); | ||||
| 
 | ||||
| conexion::conexion(config_reader &config) | ||||
| { | ||||
|   this->config=&config; | ||||
|   this->data=new msql_acces(); | ||||
| } | ||||
| 
 | ||||
| int conexion::create_socket(int port) | ||||
| { | ||||
|     int s; | ||||
|     struct sockaddr_in addr; | ||||
| 
 | ||||
|     addr.sin_family = AF_INET; | ||||
|     addr.sin_port = htons(port); | ||||
|     addr.sin_addr.s_addr = htonl(INADDR_ANY); | ||||
| 
 | ||||
|     s = socket(AF_INET, SOCK_STREAM, 0); | ||||
|     if (s < 0) { | ||||
|     perror("Unable to create socket"); | ||||
|     exit(EXIT_FAILURE); | ||||
|     } | ||||
| 
 | ||||
|     if (bind(s, (struct sockaddr*)&addr, sizeof(addr)) < 0) { | ||||
|     perror("Unable to bind"); | ||||
|     exit(EXIT_FAILURE); | ||||
|     } | ||||
| 
 | ||||
|     if (listen(s, 1) < 0) { | ||||
|     perror("Unable to listen"); | ||||
|     exit(EXIT_FAILURE); | ||||
|     } | ||||
| 
 | ||||
|     return s; | ||||
| } | ||||
| 
 | ||||
| void conexion::start_server(){ | ||||
|   int sock; | ||||
|   string port; | ||||
|   if(!this->config->get_param("port", port)){ | ||||
|       perror("bad port in config file"); | ||||
|     } | ||||
|   sock = this->create_socket(atoi(port.data())); | ||||
| 
 | ||||
|   while(1) { | ||||
|       struct sockaddr_in addr; | ||||
|       uint len = sizeof(addr); | ||||
|       int client = accept(sock, (struct sockaddr*)&addr, &len); | ||||
|       std::thread t_client(conexion_client , client); | ||||
|       t_client.detach(); | ||||
|       //cont++;
 | ||||
|   } | ||||
|   close(sock); | ||||
| } | ||||
| 
 | ||||
| bool conexion::check_pass(std::string username, std::string passwd){ | ||||
|   return passwd==this->data->get_passwd(username); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void conexion_client(int client){ | ||||
|   char     buf [256]; | ||||
| 
 | ||||
|   if (client < 0) { | ||||
|       perror("Unable to accept"); | ||||
|       exit(EXIT_FAILURE); | ||||
|   }else{ | ||||
|       session_manager* session = new session_manager(client); | ||||
|       while(session->validate_pass()); | ||||
|       session->execute(); | ||||
|       delete (session); | ||||
|       close(client); | ||||
|   } | ||||
| } | ||||
							
								
								
									
										18
									
								
								conexion.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								conexion.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| #ifndef CONEXION_H | ||||
| #define CONEXION_H | ||||
| #include <string> | ||||
| #include "config_reader.h" | ||||
| #include "data_acces.h" | ||||
| using namespace std; | ||||
| class conexion | ||||
| { | ||||
| public: | ||||
|     conexion(config_reader &conf); | ||||
|     virtual void start_server(); | ||||
|     bool check_pass(std::string username, std::string passwd); | ||||
| protected: | ||||
|     data_acces* data; | ||||
|     int create_socket(int port); | ||||
|     config_reader* config; | ||||
| }; | ||||
| #endif // CONEXION_H
 | ||||
							
								
								
									
										133
									
								
								conexion_ssl.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										133
									
								
								conexion_ssl.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,133 @@ | ||||
| #include "conexion_ssl.h" | ||||
| #include "session_manager.h" | ||||
| #include "session_manager_ssl.h" | ||||
| #include "config_reader.h" | ||||
| 
 | ||||
| #include <stdio.h> | ||||
| #include <cstring> | ||||
| #include <unistd.h> | ||||
| #include <string.h> | ||||
| #include <arpa/inet.h> | ||||
| #include <openssl/err.h> | ||||
| #include <thread> | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| void init_openssl(); | ||||
| void cleanup_openssl(); | ||||
| SSL_CTX *create_context(); | ||||
| void conexion_client(SSL_CTX *ctx,int client); | ||||
| 
 | ||||
| conexion_ssl::conexion_ssl(config_reader &conf):conexion(conf) | ||||
| { | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void conexion_ssl::start_server(){ | ||||
|   int sock; | ||||
|   string port; | ||||
|   if(!this->config->get_param("port", port)){ | ||||
|       perror("bad port in config file"); | ||||
|     } | ||||
|   sock = this->create_socket(atoi(port.data())); | ||||
|   /* Handle connections */ | ||||
|   SSL_CTX *ctx; | ||||
| 
 | ||||
|   init_openssl(); | ||||
|   ctx = create_context(); | ||||
| 
 | ||||
|   this->configure_context(ctx); | ||||
| 
 | ||||
|   //std::thread *hilos=new thread[50];
 | ||||
|   //int cont=0;
 | ||||
|   while(1) { | ||||
|       struct sockaddr_in addr; | ||||
|       uint len = sizeof(addr); | ||||
|       int client = accept(sock, (struct sockaddr*)&addr, &len); | ||||
|       std::thread t_client(conexion_client,ctx , client); | ||||
|       t_client.detach(); | ||||
|       //cont++;
 | ||||
|   } | ||||
|   close(sock); | ||||
|   SSL_CTX_free(ctx); | ||||
|   cleanup_openssl(); | ||||
| } | ||||
| 
 | ||||
| void init_openssl() | ||||
| { | ||||
|     SSL_load_error_strings(); | ||||
|     OpenSSL_add_ssl_algorithms(); | ||||
| } | ||||
| 
 | ||||
| void cleanup_openssl() | ||||
| { | ||||
|     EVP_cleanup(); | ||||
| } | ||||
| 
 | ||||
| SSL_CTX* conexion_ssl::create_context() | ||||
| { | ||||
|     const SSL_METHOD *method; | ||||
|     SSL_CTX *ctx; | ||||
| 
 | ||||
|     method = SSLv23_server_method(); | ||||
| 
 | ||||
|     ctx = SSL_CTX_new(method); | ||||
|     if (!ctx) { | ||||
|     perror("Unable to create SSL context"); | ||||
|     ERR_print_errors_fp(stderr); | ||||
|     exit(EXIT_FAILURE); | ||||
|     } | ||||
| 
 | ||||
|     return ctx; | ||||
| } | ||||
| 
 | ||||
| void conexion_ssl::configure_context(SSL_CTX *ctx) | ||||
| { | ||||
|     SSL_CTX_set_ecdh_auto(ctx, 1); | ||||
| 
 | ||||
|     /* Set the key and cert */ | ||||
| 
 | ||||
|     string cert; | ||||
|     if(!this->config->get_param("cert", cert)){ | ||||
|         perror("bad cert in config file"); | ||||
|       } | ||||
|     if (SSL_CTX_use_certificate_file(ctx, cert.data(), SSL_FILETYPE_PEM) <= 0) { | ||||
|         ERR_print_errors_fp(stderr); | ||||
|     exit(EXIT_FAILURE); | ||||
|     } | ||||
| 
 | ||||
|     string key; | ||||
|     if(!this->config->get_param("key", key)){ | ||||
|         perror("bad key in config file"); | ||||
|       } | ||||
|     if (SSL_CTX_use_PrivateKey_file(ctx, key.data(), SSL_FILETYPE_PEM) <= 0 ) { | ||||
|         ERR_print_errors_fp(stderr); | ||||
|     exit(EXIT_FAILURE); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void conexion_client(SSL_CTX *ctx,int client){ | ||||
|   char     buf [256]; | ||||
| 
 | ||||
|   if (client < 0) { | ||||
|       perror("Unable to accept"); | ||||
|       exit(EXIT_FAILURE); | ||||
|   }else{ | ||||
|       SSL *ssl; | ||||
|       ssl = SSL_new(ctx); | ||||
|       SSL_set_fd(ssl, client); | ||||
| 
 | ||||
|       if (SSL_accept(ssl) <= 0) { | ||||
|           ERR_print_errors_fp(stderr); | ||||
|       } | ||||
|       else { | ||||
|           session_manager* session = new session_manager_ssl(ssl); | ||||
|           while(!session->validate_pass()); | ||||
|           session->execute(); | ||||
|           //SSL_write(ssl,std::to_string(la->execute()).data() , sizeof (int));
 | ||||
|           delete (session); | ||||
|         } | ||||
|       SSL_shutdown(ssl); | ||||
|       SSL_free(ssl); | ||||
|       close(client); | ||||
|   } | ||||
| } | ||||
							
								
								
									
										19
									
								
								conexion_ssl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								conexion_ssl.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| #ifndef CONEXION_SSL_H | ||||
| #define CONEXION_SSL_H | ||||
| #include "conexion.h" | ||||
| 
 | ||||
| #include <openssl/ssl.h> | ||||
| 
 | ||||
| class conexion_ssl : public conexion | ||||
| { | ||||
| public: | ||||
|     conexion_ssl(config_reader &conf); | ||||
|     void start_server(); | ||||
| private: | ||||
|     /*void init_openssl();
 | ||||
|     void cleanup_openssl();*/ | ||||
|     SSL_CTX *create_context(); | ||||
|     void configure_context(SSL_CTX *ctx); | ||||
| }; | ||||
| 
 | ||||
| #endif // CONEXION_SSL_H
 | ||||
							
								
								
									
										19
									
								
								config_package.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								config_package.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| #include "config_package.h" | ||||
| 
 | ||||
| config_package::config_package(std::string name) : name(name){ | ||||
|   this->file = std::fstream("/etc/portage/package.use/"+name, std::ifstream::in); | ||||
| 
 | ||||
|   for(std::string line; std::getline(this->file, line);){ | ||||
|       this->uses+=line+"\n"; | ||||
|     } | ||||
|   this->file.close(); | ||||
| } | ||||
| 
 | ||||
| void config_package::change_uses(std::string remote_uses){ | ||||
|   if(remote_uses!=this->uses){ | ||||
|       this->file=std::fstream("/etc/portage/package.use/"+name, std::ofstream::out); | ||||
|       this->file << remote_uses; | ||||
|       this->file.close(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
							
								
								
									
										17
									
								
								config_package.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								config_package.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | ||||
| #ifndef CONFIG_PACKAGE_H | ||||
| #define CONFIG_PACKAGE_H | ||||
| #include <string> | ||||
| #include <fstream> | ||||
| 
 | ||||
| class config_package | ||||
| { | ||||
| public: | ||||
|   config_package(std::string name); | ||||
|   void change_uses(std::string remote_uses); | ||||
| private: | ||||
|   std::string name; | ||||
|   std::string uses; | ||||
|   std::fstream file; | ||||
| }; | ||||
| 
 | ||||
| #endif // CONFIG_PACKAGE_H
 | ||||
							
								
								
									
										27
									
								
								config_reader.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								config_reader.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | ||||
| #include "config_reader.h" | ||||
| #include <iostream> | ||||
| config_reader::config_reader(std::string dir) | ||||
| { | ||||
|   this->file.open(dir, std::ios::in); | ||||
|   std::string prueba; | ||||
|   std::getline(file, prueba); | ||||
| } | ||||
| 
 | ||||
| bool config_reader::get_param(std::string variable, std::string &value){ | ||||
|   this->file.clear(); | ||||
|   this->file.seekg(0, file.beg); | ||||
|   std::string line; | ||||
|   while(std::getline(file, line)){ | ||||
|     std::string no_coment=line.substr(0,line.find("#")); | ||||
|     std::size_t found=no_coment.find(variable); | ||||
|     if(found!=std::string::npos){ | ||||
|         no_coment=no_coment.substr(found+variable.length(), no_coment.length()); | ||||
|         found=no_coment.find("="); | ||||
|         if(found!=std::string::npos){ | ||||
|             value=no_coment.substr(found+1, no_coment.length()); | ||||
|             return true; | ||||
|           } | ||||
|       } | ||||
|   } | ||||
|   return false; | ||||
| } | ||||
							
								
								
									
										15
									
								
								config_reader.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								config_reader.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| #ifndef CONFIG_READER_H | ||||
| #define CONFIG_READER_H | ||||
| #include <string> | ||||
| #include <fstream> | ||||
| 
 | ||||
| class config_reader | ||||
| { | ||||
| public: | ||||
|   config_reader(std::string); | ||||
|   bool get_param(std::string variable, std::string &value); | ||||
| private: | ||||
|   std::ifstream file; | ||||
| }; | ||||
| 
 | ||||
| #endif // CONFIG_READER_H
 | ||||
							
								
								
									
										6
									
								
								data_acces.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								data_acces.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| #include "data_acces.h" | ||||
| 
 | ||||
| data_acces::data_acces() | ||||
| { | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										13
									
								
								data_acces.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								data_acces.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,13 @@ | ||||
| #ifndef DATA_ACCES_H | ||||
| #define DATA_ACCES_H | ||||
| 
 | ||||
| #include <iostream> | ||||
| 
 | ||||
| class data_acces | ||||
| { | ||||
| public: | ||||
|   data_acces(); | ||||
|   virtual std::string get_passwd(std::string username) = 0; | ||||
| }; | ||||
| 
 | ||||
| #endif // DATA_ACCES_H
 | ||||
							
								
								
									
										41
									
								
								main.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								main.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | ||||
| #include <iostream> | ||||
| #include <cstdlib> | ||||
| 
 | ||||
| #include "conexion.h" | ||||
| #include "conexion_ssl.h" | ||||
| #include "config_reader.h" | ||||
| #include "tests.h" | ||||
| 
 | ||||
| #define file_config "config" | ||||
| CPPUNIT_TEST_SUITE_REGISTRATION( test_basic ); | ||||
| int main() | ||||
| { | ||||
|   //inicio de los tests
 | ||||
|   CPPUNIT_NS::TestResult testresult; | ||||
|   CPPUNIT_NS::TestResultCollector collectedresults; | ||||
|   testresult.addListener (&collectedresults); | ||||
|   CPPUNIT_NS::BriefTestProgressListener progress; | ||||
|   testresult.addListener (&progress); | ||||
|   CPPUNIT_NS::TestRunner testrunner; | ||||
|   testrunner.addTest (CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest ()); | ||||
|   testrunner.run(testresult); | ||||
|   CPPUNIT_NS::CompilerOutputter compileroutputter(&collectedresults, std::cerr); | ||||
|   compileroutputter.write (); | ||||
| 
 | ||||
|   config_reader conf = config_reader(file_config); | ||||
|   string option; | ||||
|   if(conf.get_param("security",option)){ | ||||
|       conexion *con=nullptr; | ||||
|       if(option=="yes"){ | ||||
|           con = new conexion_ssl(conf); | ||||
|         }else if(option=="no"){ | ||||
|           con = new conexion(conf); | ||||
|         }else{ | ||||
|           perror("unknow option in security option"); | ||||
|         } | ||||
|       con->start_server(); | ||||
|     }else{ | ||||
|       perror("no define security option"); | ||||
|     } | ||||
|   return 0; | ||||
| } | ||||
							
								
								
									
										20
									
								
								msql_acces.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								msql_acces.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| #include "msql_acces.h" | ||||
| #include <iostream> | ||||
| msql_acces::msql_acces() | ||||
| { | ||||
|   driver = get_driver_instance(); | ||||
|   con = driver->connect("tcp://127.0.0.1:3306", "root", "1234"); | ||||
|   con->setSchema("bin_database"); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| std::string msql_acces::get_passwd(std::string username){ | ||||
|   sql::PreparedStatement *pstmt = con->prepareStatement("select passwd from users where username=?"); | ||||
|   pstmt->setString(1,username); | ||||
|   sql::ResultSet *res = pstmt->executeQuery(); | ||||
|   std::string ret; | ||||
|   while(res->next()) | ||||
|     ret = res->getString("passwd"); | ||||
|   delete res; | ||||
|   return ret; | ||||
| } | ||||
							
								
								
									
										21
									
								
								msql_acces.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								msql_acces.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| #ifndef MSQL_ACCES_H | ||||
| #define MSQL_ACCES_H | ||||
| #include "data_acces.h" | ||||
| 
 | ||||
| #include <cppconn/driver.h> | ||||
| #include <cppconn/exception.h> | ||||
| #include <cppconn/resultset.h> | ||||
| #include <cppconn/statement.h> | ||||
| #include <cppconn/prepared_statement.h> | ||||
| 
 | ||||
| class msql_acces : public data_acces | ||||
| { | ||||
| public: | ||||
|   msql_acces(); | ||||
|   std::string get_passwd(std::string username); | ||||
| private: | ||||
|   sql::Connection *con; | ||||
|   sql::Driver *driver; | ||||
| }; | ||||
| 
 | ||||
| #endif // MSQL_ACCES_H
 | ||||
							
								
								
									
										81
									
								
								session_manager.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								session_manager.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,81 @@ | ||||
| #include "session_manager.h" | ||||
| #include "msql_acces.h" | ||||
| 
 | ||||
| #include <unistd.h> | ||||
| #include <sys/wait.h> | ||||
| #include <iostream> | ||||
| #include <cstring> | ||||
| 
 | ||||
| session_manager::session_manager(int fd) | ||||
| { | ||||
|   this->fd=fd; | ||||
|   this->data=new msql_acces(); | ||||
| } | ||||
| 
 | ||||
| bool session_manager::validate_pass(){ | ||||
|   char* buffer = new char[256]; | ||||
|   this->read_data(buffer, 256); | ||||
|   std::string user=buffer; | ||||
|   this->read_data(buffer, 256); | ||||
|   std::string pass=buffer; | ||||
|   if(this->data->get_passwd(user)==pass){ | ||||
|       this->write_data("pass"); | ||||
|       return true; | ||||
|     }else{ | ||||
|       this->write_data("fail"); | ||||
|       return false; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void session_manager::start_dialog(){ | ||||
|   char* buffer = new char[5]; | ||||
|   while(true){ | ||||
|       this->read_data(buffer,5); | ||||
|       if(strcmp(buffer, "exec")==0){ | ||||
|           this->execute(); | ||||
|         }else if(strcmp(buffer, "info")==0){ | ||||
|           this->send_information(); | ||||
|         }else if(strcmp(buffer,"exit")){ | ||||
|           break; | ||||
|         } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| int session_manager::execute(){ | ||||
|   char* n_package = new char[256]; | ||||
|   this->read_data(n_package, 256); | ||||
|   this->args=new char*[4]; | ||||
|     this->args[0]="emerge"; | ||||
|     this->args[1]="--ask"; | ||||
|     this->args[2]=n_package; | ||||
|     this->args[3]=nullptr; | ||||
|   int pid = fork(); | ||||
|   int status=-2; | ||||
|   if(pid==0){ | ||||
|       if(execvp(this->args[0],this->args)==-1){ | ||||
|           std::cout << "error inesperado" << std::endl; | ||||
|         } | ||||
|       exit(0); | ||||
|   }else { | ||||
|     waitpid(pid, &status, WCONTINUED); | ||||
|     if(status>0){ | ||||
|         this->write_data("ok"); | ||||
|       }else{ | ||||
|         this->write_data("bad"); | ||||
|       } | ||||
|   } | ||||
|   delete[] (n_package); | ||||
|   return status; | ||||
| } | ||||
| 
 | ||||
| void session_manager::send_information(){ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| int session_manager::read_data(char* input, int size){ | ||||
|   return read(this->fd, input, size); | ||||
| } | ||||
| 
 | ||||
| int session_manager::write_data(std::string output){ | ||||
|   return write(this->fd, output.data(), output.size()); | ||||
| } | ||||
							
								
								
									
										21
									
								
								session_manager.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								session_manager.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| #ifndef LAUNCHER_H | ||||
| #define LAUNCHER_H | ||||
| #include <iostream> | ||||
| #include <data_acces.h> | ||||
| class session_manager | ||||
| { | ||||
| public: | ||||
|   session_manager(int fd); | ||||
|   void start_dialog(); | ||||
|   int execute(); | ||||
|   void send_information(); | ||||
|   bool validate_pass(); | ||||
|  private: | ||||
|   virtual int read_data(char* input, int size); | ||||
|   virtual int write_data(std::string output); | ||||
|   int fd; | ||||
|   data_acces* data; | ||||
|   char** args; | ||||
| }; | ||||
| 
 | ||||
| #endif // LAUNCHER_H
 | ||||
							
								
								
									
										14
									
								
								session_manager_ssl.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								session_manager_ssl.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | ||||
| #include "session_manager_ssl.h" | ||||
| 
 | ||||
| session_manager_ssl::session_manager_ssl(SSL* sfd):session_manager(-1) | ||||
| { | ||||
|   this->sfd=sfd; | ||||
| } | ||||
| 
 | ||||
| int session_manager_ssl::read_data(char* input, int size){ | ||||
|   return SSL_read(this->sfd, input, size); | ||||
| } | ||||
| 
 | ||||
| int session_manager_ssl::write_data(std::string output){ | ||||
|   return SSL_write(this->sfd, output.data(), output.size()); | ||||
| } | ||||
							
								
								
									
										16
									
								
								session_manager_ssl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								session_manager_ssl.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| #ifndef SESSION_MANAGER_SSL_H | ||||
| #define SESSION_MANAGER_SSL_H | ||||
| #include <openssl/ssl.h> | ||||
| #include "session_manager.h" | ||||
| 
 | ||||
| class session_manager_ssl : public session_manager | ||||
| { | ||||
| public: | ||||
|   session_manager_ssl(SSL* fd); | ||||
|   int read_data(char* input, int size); | ||||
|   int write_data(std::string output); | ||||
| private: | ||||
|   SSL* sfd; | ||||
| }; | ||||
| 
 | ||||
| #endif // SESSION_MANAGER_SSL_H
 | ||||
							
								
								
									
										22
									
								
								tests.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								tests.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| #include "tests.h" | ||||
| 
 | ||||
| void test_basic::setUp(){ | ||||
|   this->conf=new config_reader("config"); | ||||
| } | ||||
| 
 | ||||
| void test_basic::testInitial(){ | ||||
|   std::string res; | ||||
|   CPPUNIT_ASSERT(true==this->conf->get_param("port",res)); | ||||
|   CPPUNIT_ASSERT("4433"==res); | ||||
| } | ||||
| 
 | ||||
| void test_basic::pass_tests(){ | ||||
|   CPPUNIT_NS::TestResult testresult; | ||||
|   CPPUNIT_NS::TestResultCollector collectedresults; | ||||
|   testresult.addListener (&collectedresults); | ||||
|   CPPUNIT_NS::BriefTestProgressListener progress; | ||||
|   testresult.addListener (&progress); | ||||
|   CPPUNIT_NS::TestRunner testrunner; | ||||
|   testrunner.addTest (CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest ()); | ||||
|   testrunner.run(testresult); | ||||
| } | ||||
							
								
								
									
										28
									
								
								tests.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| #ifndef TESTS_H | ||||
| #define TESTS_H | ||||
| #include <cppunit/TestCase.h> | ||||
| #include <cppunit/TestFixture.h> | ||||
| #include <cppunit/ui/text/TextTestRunner.h> | ||||
| #include <cppunit/extensions/HelperMacros.h> | ||||
| #include <cppunit/extensions/TestFactoryRegistry.h> | ||||
| #include <cppunit/TestResult.h> | ||||
| #include <cppunit/TestResultCollector.h> | ||||
| #include <cppunit/TestRunner.h> | ||||
| #include <cppunit/BriefTestProgressListener.h> | ||||
| #include <cppunit/CompilerOutputter.h> | ||||
| #include <cppunit/XmlOutputter.h> | ||||
| #include "config_reader.h" | ||||
| using namespace CppUnit; | ||||
| 
 | ||||
| class test_basic : public CppUnit::TestFixture{ | ||||
|   CPPUNIT_TEST_SUITE(test_basic); | ||||
|   CPPUNIT_TEST(testInitial); | ||||
|   CPPUNIT_TEST_SUITE_END(); | ||||
| public: | ||||
|   void setUp(void); | ||||
|   void pass_tests(); | ||||
| private: | ||||
|   void testInitial(void); | ||||
|   config_reader *conf; | ||||
| }; | ||||
| #endif // TESTS_H
 | ||||
							
								
								
									
										6
									
								
								thread_selector.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								thread_selector.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| #include "thread_selector.h" | ||||
| 
 | ||||
| thread_selector::thread_selector() | ||||
| { | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										15
									
								
								thread_selector.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								thread_selector.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| #ifndef THREAD_SELECTOR_H | ||||
| #define THREAD_SELECTOR_H | ||||
| #include <queue> | ||||
| #include <thread> | ||||
| 
 | ||||
| class thread_selector | ||||
| { | ||||
| public: | ||||
|   thread_selector(); | ||||
| private: | ||||
|   std::queue<int> t_pos; | ||||
|   std::thread* list; | ||||
| }; | ||||
| 
 | ||||
| #endif // THREAD_SELECTOR_H
 | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user